GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/publish/except.h
Date: 2024-04-28 02:33:07
Exec Total Coverage
Lines: 0 6 0.0%
Branches: 0 10 0.0%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #ifndef CVMFS_PUBLISH_EXCEPT_H_
6 #define CVMFS_PUBLISH_EXCEPT_H_
7
8 #include <stdexcept>
9 #include <string>
10
11 namespace publish {
12
13 class EPublish : public std::runtime_error {
14 public:
15 /**
16 * Well-known exceptions that are usually caught and handled
17 */
18 enum EFailures {
19 kFailUnspecified = 0,
20 kFailInput, // Invalid input
21 kFailInvocation, // Invalid command line options
22 kFailPermission, // Not owner of the repository
23 kFailTransactionState, // The txn was expected to be in the other state
24 kFailGatewayKey, // cannot access the gateway secret key
25 kFailLeaseHttp, // cannot connect to the gateway HTTP endpoint
26 kFailLeaseBody, // corrupted session token
27 kFailLeaseBusy, // another active lease blocks the path
28 kFailLeaseNoEntry, // the lease path does not exist
29 kFailLeaseNoDir, // the lease path is no a directory
30 kFailRepositoryNotFound, // the repository was not found on the machine
31 kFailRepositoryType, // the stratum type (0, 1) does not match
32 kFailLayoutRevision, // unsupported layout revision, migrate required
33 kFailWhitelistExpired, //
34 kFailMissingDependency, // a program or service was not found
35 };
36
37 explicit EPublish(const std::string& what, EFailures f = kFailUnspecified)
38 : std::runtime_error(what + "\n\nStacktrace:\n" + GetStacktrace())
39 , failure_(f)
40 , msg_holder_(what)
41 {}
42
43 virtual ~EPublish() throw();
44
45 EFailures failure() const { return failure_; }
46 std::string msg() const { return msg_holder_.what(); }
47
48 private:
49 EFailures failure_;
50 // We cannot use an std::string because it would make the EPublish copy
51 // constructor exception unsafe.
52 std::runtime_error msg_holder_;
53
54 /**
55 * Maximum number of frames in the stack trace
56 */
57 static const unsigned kMaxBacktrace = 64;
58 static std::string GetStacktrace();
59 };
60
61 } // namespace publish
62
63 #endif // CVMFS_PUBLISH_EXCEPT_H_
64