Skip to content

Commit

Permalink
Added the HTTPError class + Added the 'ExpectedAFileResourceType' sta…
Browse files Browse the repository at this point in the history
…ndard error
  • Loading branch information
AdrienCastex committed May 25, 2017
1 parent 470b15e commit c60f5dd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Errors.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
export declare class ManagerNotFound extends Error {
constructor(managerUID: string);
}
export declare class HTTPError extends Error {
HTTPCode: number;
inheritedError: Error;
constructor(HTTPCode: number, inheritedError?: Error);
}
export declare const Errors: {
BadAuthentication: Error;
AuenticationPropertyMissing: Error;
Expand All @@ -16,6 +21,7 @@ export declare const Errors: {
AlreadyAuthenticated: Error;
UserNotFound: Error;
XMLNotFound: Error;
ExpectedAFileResourceType: Error;
None: any;
};
export default Errors;
12 changes: 12 additions & 0 deletions lib/Errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ var ManagerNotFound = (function (_super) {
return ManagerNotFound;
}(Error));
exports.ManagerNotFound = ManagerNotFound;
var HTTPError = (function (_super) {
__extends(HTTPError, _super);
function HTTPError(HTTPCode, inheritedError) {
var _this = _super.call(this, 'Error ' + HTTPCode) || this;
_this.HTTPCode = HTTPCode;
_this.inheritedError = inheritedError;
return _this;
}
return HTTPError;
}(Error));
exports.HTTPError = HTTPError;
exports.Errors = {
BadAuthentication: new Error('Bad authentication'),
AuenticationPropertyMissing: new Error('Properties are missing'),
Expand All @@ -33,6 +44,7 @@ exports.Errors = {
AlreadyAuthenticated: new Error('Already authenticated'),
UserNotFound: new Error('User not found'),
XMLNotFound: new Error('Can\'t find the XML element.'),
ExpectedAFileResourceType: new Error('Expected a file resource type.'),
None: null
};
exports.default = exports.Errors;
9 changes: 9 additions & 0 deletions 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 HTTPError extends Error
{
constructor(public HTTPCode : number, public inheritedError ?: Error)
{
super('Error ' + HTTPCode)
}
}

export const Errors = {
BadAuthentication: new Error('Bad authentication'),
AuenticationPropertyMissing: new Error('Properties are missing'),
Expand All @@ -22,6 +30,7 @@ export const Errors = {
AlreadyAuthenticated: new Error('Already authenticated'),
UserNotFound: new Error('User not found'),
XMLNotFound: new Error('Can\'t find the XML element.'),
ExpectedAFileResourceType: new Error('Expected a file resource type.'),

None: null
};
Expand Down

0 comments on commit c60f5dd

Please sign in to comment.