Skip to content

Commit

Permalink
Added an error class for unserialization error (when the serializer i…
Browse files Browse the repository at this point in the history
…s not found) + Added an error in the 'Errors' bundle to say that the user has not enough privilege
  • Loading branch information
AdrienCastex committed Jun 28, 2017
1 parent 5c04125 commit f488ecc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/Errors.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ export declare class ManagerNotFound extends Error {
managerUID: string;
constructor(managerUID: string);
}
export declare class SerializerNotFound extends Error {
serializerUID: string;
constructor(serializerUID: string);
}
export declare class HTTPError extends Error {
HTTPCode: number;
inheritedError: Error;
Expand All @@ -28,11 +32,11 @@ export declare const Errors: {
NoSizeForAFolder: Error;
IllegalArguments: Error;
MustIgnore: Error;
SerializerNotFound: Error;
Locked: Error;
InsufficientStorage: Error;
IntermediateResourceMissing: Error;
WrongParentTypeForCreation: Error;
NotEnoughPrivilege: Error;
None: any;
};
export default Errors;
12 changes: 11 additions & 1 deletion lib/Errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ var ManagerNotFound = (function (_super) {
return ManagerNotFound;
}(Error));
exports.ManagerNotFound = ManagerNotFound;
var SerializerNotFound = (function (_super) {
__extends(SerializerNotFound, _super);
function SerializerNotFound(serializerUID) {
var _this = _super.call(this, 'Cannot find the serializer : ' + serializerUID) || this;
_this.serializerUID = serializerUID;
return _this;
}
return SerializerNotFound;
}(Error));
exports.SerializerNotFound = SerializerNotFound;
var HTTPError = (function (_super) {
__extends(HTTPError, _super);
function HTTPError(HTTPCode, inheritedError) {
Expand Down Expand Up @@ -53,11 +63,11 @@ exports.Errors = {
NoSizeForAFolder: new Error('Cannot get the size of a folder type resource.'),
IllegalArguments: new Error('Illegal arguments.'),
MustIgnore: new Error('There was an error but it must not stop the processing.'),
SerializerNotFound: new Error('One serializer could not be found.'),
Locked: new Error('The resource is locked, operation forbidden.'),
InsufficientStorage: new Error('Insufficient storage space.'),
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.'),
None: null
};
exports.default = exports.Errors;
10 changes: 9 additions & 1 deletion src/Errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ export class ManagerNotFound extends Error
}
}

export class SerializerNotFound extends Error
{
constructor(public serializerUID : string)
{
super('Cannot find the serializer : ' + serializerUID);
}
}

export class HTTPError extends Error
{
constructor(public HTTPCode : number, public inheritedError ?: Error)
Expand Down Expand Up @@ -38,11 +46,11 @@ export const Errors = {
NoSizeForAFolder: new Error('Cannot get the size of a folder type resource.'),
IllegalArguments: new Error('Illegal arguments.'),
MustIgnore: new Error('There was an error but it must not stop the processing.'),
SerializerNotFound: new Error('One serializer could not be found.'),
Locked: new Error('The resource is locked, operation forbidden.'),
InsufficientStorage: new Error('Insufficient storage space.'),
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.'),

None: null
};
Expand Down

0 comments on commit f488ecc

Please sign in to comment.