From a209249c3a53b0cdb88eb021bcaf25fd6a78ff45 Mon Sep 17 00:00:00 2001 From: Adrien Castex Date: Thu, 29 Jun 2017 16:17:28 +0200 Subject: [PATCH] Added the 'Forbidden' standard error --- lib/Errors.d.ts | 1 + lib/Errors.js | 1 + lib/server/v2/RequestContext.js | 2 ++ src/Errors.ts | 1 + src/server/v2/RequestContext.ts | 2 ++ 5 files changed, 7 insertions(+) diff --git a/lib/Errors.d.ts b/lib/Errors.d.ts index 4a401a7e..4b368901 100644 --- a/lib/Errors.d.ts +++ b/lib/Errors.d.ts @@ -37,6 +37,7 @@ export declare const Errors: { IntermediateResourceMissing: Error; WrongParentTypeForCreation: Error; NotEnoughPrivilege: Error; + Forbidden: Error; None: any; }; export default Errors; diff --git a/lib/Errors.js b/lib/Errors.js index fef58248..b51725a4 100644 --- a/lib/Errors.js +++ b/lib/Errors.js @@ -68,6 +68,7 @@ exports.Errors = { IntermediateResourceMissing: new Error('One or more intermediate resources are missing for this operation.'), WrongParentTypeForCreation: new Error('Cannot create a child resource to a non directory resource.'), NotEnoughPrivilege: new Error('Not enough privilege.'), + Forbidden: new Error('Forbidden operation.'), None: null }; exports.default = exports.Errors; diff --git a/lib/server/v2/RequestContext.js b/lib/server/v2/RequestContext.js index bae90ead..b12691dc 100644 --- a/lib/server/v2/RequestContext.js +++ b/lib/server/v2/RequestContext.js @@ -288,6 +288,8 @@ var RequestContext = (function () { code = HTTPCodes_1.HTTPCodes.Conflict; else if (error === Errors_1.Errors.InsufficientStorage) code = HTTPCodes_1.HTTPCodes.InsufficientStorage; + else if (error === Errors_1.Errors.Forbidden) + code = HTTPCodes_1.HTTPCodes.Forbidden; return code; }; RequestContext.prototype.setCodeFromError = function (error) { diff --git a/src/Errors.ts b/src/Errors.ts index c480fce9..61f659c6 100644 --- a/src/Errors.ts +++ b/src/Errors.ts @@ -51,6 +51,7 @@ export const Errors = { IntermediateResourceMissing: new Error('One or more intermediate resources are missing for this operation.'), WrongParentTypeForCreation: new Error('Cannot create a child resource to a non directory resource.'), NotEnoughPrivilege: new Error('Not enough privilege.'), + Forbidden: new Error('Forbidden operation.'), None: null }; diff --git a/src/server/v2/RequestContext.ts b/src/server/v2/RequestContext.ts index 628f7774..c3666bcb 100644 --- a/src/server/v2/RequestContext.ts +++ b/src/server/v2/RequestContext.ts @@ -392,6 +392,8 @@ export class RequestContext code = HTTPCodes.Conflict; else if(error === Errors.InsufficientStorage) code = HTTPCodes.InsufficientStorage; + else if(error === Errors.Forbidden) + code = HTTPCodes.Forbidden; return code; }