CernVM-FS  2.12.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 
43  virtual ~EPublish() throw();
44 
45  EFailures failure() const { return failure_; }
46  std::string msg() const { return msg_holder_.what(); }
47 
48  private:
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 
57  static const unsigned kMaxBacktrace = 64;
58  static std::string GetStacktrace();
59 };
60 
61 } // namespace publish
62 
63 #endif // CVMFS_PUBLISH_EXCEPT_H_
EFailures failure_
Definition: except.h:49
EPublish(const std::string &what, EFailures f=kFailUnspecified)
Definition: except.h:37
std::string msg() const
Definition: except.h:46
std::runtime_error msg_holder_
Definition: except.h:52
virtual ~EPublish()
Definition: except.cc:11
EFailures failure() const
Definition: except.h:45
static std::string GetStacktrace()
Definition: except.cc:13
static const unsigned kMaxBacktrace
Definition: except.h:57