-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy patherrors.js
More file actions
35 lines (27 loc) · 694 Bytes
/
errors.js
File metadata and controls
35 lines (27 loc) · 694 Bytes
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
var util = require('util');
/**
Custom Errors used in order to distinguish them from generic Errors:
// distinguish from generic errors
try {
throw new errors.PeliasModelError('error');
}
catch (c) {
switch( c.name ){
case 'PeliasModelError':
// not a generic error
break;
default:
// generic error
}
}
**/
// Custom Error - PeliasModelError
function PeliasModelError(message) {
Error.captureStackTrace(this, this.constructor);
this.name = 'PeliasModelError';
this.message = message;
}
// Extends from js Error object
util.inherits(PeliasModelError, Error);
// export
module.exports.PeliasModelError = PeliasModelError;