All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
validation-error.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_VALIDATION_ERROR_HPP
24 #define NDN_VALIDATION_ERROR_HPP
25 
26 #include <string>
27 #include "../../common.hpp"
28 
29 namespace ndn {
30 
35 public:
36  static const int NO_ERROR = 0;
37  static const int INVALID_SIGNATURE = 1;
38  static const int NO_SIGNATURE = 2;
39  static const int CANNOT_RETRIEVE_CERTIFICATE = 3;
40  static const int EXPIRED_CERTIFICATE = 4;
41  static const int LOOP_DETECTED = 5;
42  static const int MALFORMED_CERTIFICATE = 6;
43  static const int EXCEEDED_DEPTH_LIMIT = 7;
44  static const int INVALID_KEY_LOCATOR = 8;
45  static const int POLICY_ERROR = 9;
46  static const int IMPLEMENTATION_ERROR = 255;
47  // Custom error codes should use >= USER_MIN.
48  static const int USER_MIN = 256;
49 
56  ValidationError(int code, const std::string& info = "")
57  : code_(code), info_(info)
58  {
59  }
60 
66  int
67  getCode() const { return code_; }
68 
73  const std::string&
74  getInfo() const { return info_; }
75 
76 private:
77  int code_;
78  std::string info_;
79 };
80 
81 std::ostream&
82 operator<<(std::ostream& os, const ValidationError& error);
83 
84 }
85 
86 #endif
ValidationError(int code, const std::string &info="")
Create a new ValidationError for the given code.
Definition: validation-error.hpp:56
int getCode() const
Get the error code given to the constructor.
Definition: validation-error.hpp:67
const std::string & getInfo() const
Get the error message given to the constructor.
Definition: validation-error.hpp:74
A ValidationError holds an error code and an optional detailed error message.
Definition: validation-error.hpp:34