20 #ifndef __OPERATOR_ERROR_HH_ 21 #define __OPERATOR_ERROR_HH_ 42 virtual std::string to_string()
const = 0;
52 : description(_description)
54 std::string to_string()
const {
return description; };
56 std::string description;
64 virtual const std::string &getErrorCode()
const = 0;
65 const std::string &getError()
const {
return error; }
66 unsigned short getStatusCode()
const {
return status_code; }
67 const std::map<std::string,nlohmann::json> &getData()
const {
return other_data; }
69 static Error * newError(
unsigned short status_code,
const nlohmann::json &data)
throw ();
71 std::string to_string()
const {
return getErrorCode() +
" (" + std::to_string(getStatusCode()) +
"): " + getError(); }
73 static const char M_FORBIDDEN[];
74 static const char M_UNKNOWN_TOKEN[];
75 static const char M_BAD_JSON[];
76 static const char M_NOT_JSON[];
77 static const char M_NOT_FOUND[];
78 static const char M_LIMIT_EXCEEDED[];
79 static const char M_USER_IN_USE[];
80 static const char M_INVALID_USERNAME[];
81 static const char M_ROOM_IN_USE[];
82 static const char M_BAD_PAGINATION[];
83 static const char M_THREEPID_IN_USE[];
84 static const char M_THREEPID_NOT_FOUND[];
85 static const char M_SERVER_NOT_TRUSTED[];
86 static const char M_WEAK_PASSWORD[];
87 static const char M_UNKNOWN[];
88 static const char M_EXCLUSIVE[];
89 static const char M_MISSING_PARAM[];
91 typedef std::function<MatrixError *(unsigned short, const std::string &, const std::string &, std::map<std::string,nlohmann::json> &)> error_builder_t;
92 static void registerErrorClass(
const std::string &error_code, error_builder_t);
93 template<
typename T>
static MatrixError *_new_helper(
unsigned short _status_code,
const std::string &,
const std::string &_error, std::map<std::string,nlohmann::json> &_other_data) {
94 return new T(_status_code, _error, _other_data);
97 unsigned short status_code;
99 std::map<std::string,nlohmann::json> other_data;
101 MatrixError(
unsigned short _status_code,
const std::string &_error, std::map<std::string,nlohmann::json> &_other_data)
102 : status_code(_status_code),
104 other_data(std::move(_other_data))
110 _MatrixErr(
unsigned short _status_code, std::string _error, std::map<std::string,nlohmann::json> &_other_data)
111 :
MatrixError(_status_code, _error, _other_data) {}
113 const std::string &getErrorCode()
const {
return ERROR_CODE; }
114 static const std::string ERROR_CODE;
207 OtherMatrixError(
unsigned short _status_code,
const std::string &_error_code,
const std::string &_error, std::map<std::string,nlohmann::json> &_other_data)
209 error_code(_error_code)
211 const std::string &getErrorCode()
const {
return error_code; }
213 const std::string error_code;
218 #endif // __OPERATOR_ERROR_HH_ Unknown (possibly custom) Matrix error.
Definition: error.hh:205
The access token specified was not recognised.
Encountered when trying to register a user ID which is not valid.
The password is too weak.
Request contained valid JSON, but it was malformed in some way, e.g. missing required keys...
The desired user ID is in the exclusive namespace claimed by an application service.
Encountered when trying to register a user ID which has been taken.
Sent when a threepid given to an API cannot be used because no record matching the threepid was found...
No resource was found for this request.
The client's request used a third party server, eg. ID server, that this server does not trust...
Sent when a threepid given to an API cannot be used because the same threepid is already in use...
Request did not contain valid JSON.
Encountered when trying to create a room which has been taken.
base error class.
Definition: error.hh:37
base error class for Matrix protocol errors.
Definition: error.hh:62
invalid data error.
Definition: error.hh:49
Forbidden access, e.g. joining a room without permission, failed login.
Too many requests have been sent in a short period of time. Wait a while then try again...