CernVM-FS  2.13.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
except.h
Go to the documentation of this file.
1 
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:
18  enum EFailures {
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
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:
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 
56  static const unsigned kMaxBacktrace = 64;
57  static std::string GetStacktrace();
58 };
59 
60 } // namespace publish
61 
62 #endif // CVMFS_PUBLISH_EXCEPT_H_
EFailures failure_
Definition: except.h:48
EPublish(const std::string &what, EFailures f=kFailUnspecified)
Definition: except.h:37
std::string msg() const
Definition: except.h:45
std::runtime_error msg_holder_
Definition: except.h:51
virtual ~EPublish()
Definition: except.cc:11
EFailures failure() const
Definition: except.h:44
static std::string GetStacktrace()
Definition: except.cc:13
static const unsigned kMaxBacktrace
Definition: except.h:56