blob: 1b58a6f79742ba54c6047b1937e961706dbc43fd (
plain) (
blame)
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
|
(function(module, ns) {
Errors = {};
/**
* Errors typically are for front-end routing purposes so the important
* part really is just the name and (maybe) the symbol... These are really
* intended to be consumed by name... So once a name has been assigned it
* should never be modified.
*/
[
{ symbol: 'Authentication', name: 'authentication' },
{ symbol: 'InvalidEntrypoint', name: 'invalid-entrypoint' },
{ symbol: 'ServerFailure', name: 'server-failure' },
{ symbol: 'Unknown', name: 'unknown' }
].forEach(function createError(def) {
var obj = Errors[def.symbol] = function(message) {
this.message = message;
this.name = 'caldav-' + def.name;
try {
throw new Error();
} catch (e) {
this.stack = e.stack;
}
};
// just so instanceof Error works
obj.prototype = Object.create(Error.prototype);
});
module.exports = Errors;
}.apply(
this,
(this.Caldav) ?
[Caldav('errors'), Caldav] :
[module, require('./caldav')]
));
|