-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustomerror.js
44 lines (40 loc) · 1.73 KB
/
customerror.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//For when Skill is not linked to Amazon Account, usually handled
function NotLinkedError(message) {
this.message = message;
this.name = "NotLinkedError";
Error.captureStackTrace(this, NotLinkedError);
}
NotLinkedError.prototype = Object.create(Error.prototype);
NotLinkedError.prototype.constructor = NotLinkedError;
exports.NotLinkedError = NotLinkedError;
//For when Skill has an invalid canvas access token, usually handled
function InvalidCanvasTokenError(message) {
this.message = message;
this.name = "InvalidCanvasTokenError";
Error.captureStackTrace(this, NotLinkedError);
}
InvalidCanvasTokenError.prototype = Object.create(Error.prototype);
InvalidCanvasTokenError.prototype.constructor = InvalidCanvasTokenError;
exports.InvalidCanvasTokenError = InvalidCanvasTokenError;
//For when a bad error is predictable and you want to send a better message to the user
function PresentableError(message, orig) {
this.message = message;
this.name = "PresentableError";
this.orig = orig || null;
Error.captureStackTrace(this, PresentableError);
}
PresentableError.prototype = Object.create(Error.prototype);
PresentableError.prototype.constructor = PresentableError;
exports.PresentableError = PresentableError;
//Wrapper for handled errors, errors that require no more action, already handled elsewhere
function HandledError(message, orig) {
this.message = message;
this.name = "HandledError";
this.orig = orig || null;
Error.captureStackTrace(this, HandledError);
}
HandledError.prototype = Object.create(Error.prototype);
HandledError.prototype.constructor = HandledError;
exports.HandledError = HandledError;
//Make request promise errors accessible
exports.Request = require('request-promise/errors');