Skip to content

Commit

Permalink
Added the 'Forbidden' standard error
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienCastex committed Jun 29, 2017
1 parent 72696ad commit a209249
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Errors.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export declare const Errors: {
IntermediateResourceMissing: Error;
WrongParentTypeForCreation: Error;
NotEnoughPrivilege: Error;
Forbidden: Error;
None: any;
};
export default Errors;
1 change: 1 addition & 0 deletions lib/Errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 2 additions & 0 deletions lib/server/v2/RequestContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions src/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand Down
2 changes: 2 additions & 0 deletions src/server/v2/RequestContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a209249

Please sign in to comment.