-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientError.h
More file actions
23 lines (19 loc) · 866 Bytes
/
Copy pathClientError.h
File metadata and controls
23 lines (19 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef _CLIENT_ERROR_H_
#define _CLIENT_ERROR_H_
#include <stdexcept>
#include <string>
class ClientError : public std::runtime_error {
public:
ClientError(std::string text, int status_code) : std::runtime_error(text) {
this->status_code = status_code;
}
int status_code;
static ClientError badRequest() { return ClientError("Bad Request", 400); }
static ClientError unauthorized() { return ClientError("Unauthorized", 401); }
static ClientError forbidden() { return ClientError("Forbidden", 403); }
static ClientError notFound() { return ClientError("Not Found", 404); }
static ClientError methodNotAllowed() { return ClientError("Method Not Allowed", 405); }
static ClientError conflict() { return ClientError("Conflict", 409); }
static ClientError insufficientStorage() { return ClientError("Insufficient Storage", 507); }
};
#endif