GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/publish/except.h
Date: 2025-06-08 02:35:55
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 virtual ~EPublish() throw();
43
44 EFailures failure() const { return failure_; }
45 std::string msg() const { return msg_holder_.what(); }
46
47 private:
48 EFailures failure_;
49 // We cannot use an std::string because it would make the EPublish copy
50 // constructor exception unsafe.
51 std::runtime_error msg_holder_;
52
53 /**
54 * Maximum number of frames in the stack trace
55 */
56 static const unsigned kMaxBacktrace = 64;
57 static std::string GetStacktrace();
58 };
59
60 } // namespace publish
61
62 #endif // CVMFS_PUBLISH_EXCEPT_H_
63