diff options
author | Marius David Wieschollek <passwords.public@mdns.eu> | 2022-01-04 22:53:42 +0300 |
---|---|---|
committer | Marius David Wieschollek <passwords.public@mdns.eu> | 2022-01-04 22:53:42 +0300 |
commit | 74d7a9e3a0b5c9c8c0bc8a52c75b488c05285cbd (patch) | |
tree | 3f275c99c92bc6a4d5560acf6a6df9eecb4259d4 | |
parent | e1c6b6afe7bcefb0a8b17d70c72588d6c70f8db9 (diff) |
Added precondition failed error
Signed-off-by: Marius David Wieschollek <passwords.public@mdns.eu>
-rw-r--r-- | src/ClassLoader/DefaultClassLoader.js | 2 | ||||
-rw-r--r-- | src/Exception/Http/PreconditionFailedError.js | 18 | ||||
-rw-r--r-- | src/Network/ApiRequest.js | 4 | ||||
-rw-r--r-- | src/errors.js | 4 |
4 files changed, 25 insertions, 3 deletions
diff --git a/src/ClassLoader/DefaultClassLoader.js b/src/ClassLoader/DefaultClassLoader.js index d749664..00ff4b3 100644 --- a/src/ClassLoader/DefaultClassLoader.js +++ b/src/ClassLoader/DefaultClassLoader.js @@ -66,6 +66,7 @@ import InvalidEncryptedTextLength from "../Exception/Encryption/InvalidEncrypted import HashService from "../Services/HashService"; import Logger from "../Logger/Logger"; import DefectField from "../Model/CustomField/DefectField"; +import PreconditionFailedError from "../Exception/Http/PreconditionFailedError"; export default class DefaultClassLoader extends BasicClassLoader { @@ -147,6 +148,7 @@ export default class DefaultClassLoader extends BasicClassLoader { 'exception.http.403' : ForbiddenError, 'exception.http.404' : NotFoundError, 'exception.http.405' : MethodNotAllowedError, + 'exception.http.412' : PreconditionFailedError, 'exception.http.429' : TooManyRequestsError, 'exception.http.500' : InternalServerError, 'exception.http.502' : BadGatewayError, diff --git a/src/Exception/Http/PreconditionFailedError.js b/src/Exception/Http/PreconditionFailedError.js new file mode 100644 index 0000000..12fbad3 --- /dev/null +++ b/src/Exception/Http/PreconditionFailedError.js @@ -0,0 +1,18 @@ +import HttpError from './HttpError'; + +export default class PreconditionFailedError extends HttpError { + + /** + * @returns {String} + */ + get name() { + return 'PreconditionFailedError'; + } + + /** + * @param {Response} response + */ + constructor(response) { + super(response, 'Precondition failed'); + } +}
\ No newline at end of file diff --git a/src/Network/ApiRequest.js b/src/Network/ApiRequest.js index 1e975af..a4ce535 100644 --- a/src/Network/ApiRequest.js +++ b/src/Network/ApiRequest.js @@ -282,8 +282,8 @@ export default class ApiRequest { * @private */ _getHttpError(response) { - if([400, 401, 403, 404, 405, 429, 500, 502, 503, 504].indexOf(response.status) !== -1) { - return this._api.getClass(`exception.${response.status}`, response); + if([400, 401, 403, 404, 405, 412, 429, 500, 502, 503, 504].indexOf(response.status) !== -1) { + return this._api.getClass(`exception.http.${response.status}`, response); } if(response.status > 99) { return this._api.getClass('exception.http', response); diff --git a/src/errors.js b/src/errors.js index 225f4a5..5305bba 100644 --- a/src/errors.js +++ b/src/errors.js @@ -14,6 +14,7 @@ import NotFoundError from "./Exception/Http/NotFoundError"; import ServiceUnavailableError from "./Exception/Http/ServiceUnavailableError"; import TooManyRequestsError from "./Exception/Http/TooManyRequestsError"; import UnauthorizedError from "./Exception/Http/UnauthorizedError"; +import PreconditionFailedError from "./Exception/Http/PreconditionFailedError"; import InvalidLink from "./Exception/PassLink/InvalidLink"; import UnknownAction from "./Exception/PassLink/UnknownAction"; import ChallengeTypeNotSupported from "./Exception/ChallengeTypeNotSupported"; @@ -51,5 +52,6 @@ export { ResponseContentTypeError, ResponseDecodingError, TokenTypeNotSupported, - UnknownPropertyError + UnknownPropertyError, + PreconditionFailedError };
\ No newline at end of file |