diff options
author | Michal Budzynski <michal@virtualdesign.pl> | 2012-11-06 11:54:07 -0800 |
---|---|---|
committer | Michal Budzynski <michal@virtualdesign.pl> | 2012-11-08 16:16:07 -0800 |
commit | b74223999c5a240306132704177eb9cbb1dc9143 (patch) | |
tree | f2980f8379b9abfaebf2fe7d41d0a9415cd13517 /lib/caldav/request/errors.js | |
parent | 84c07224a04189d42abbcd2dbfaf541fa53a90ff (diff) | |
download | jsCalDAV-b74223999c5a240306132704177eb9cbb1dc9143.tar.gz |
error handler
a
error-handling
a
err
Diffstat (limited to 'lib/caldav/request/errors.js')
-rw-r--r-- | lib/caldav/request/errors.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/caldav/request/errors.js b/lib/caldav/request/errors.js new file mode 100644 index 0000000..c3c166e --- /dev/null +++ b/lib/caldav/request/errors.js @@ -0,0 +1,49 @@ +(function(module, ns) { + + function CaldavHttpError(code) { + this.code = code; + var message; + switch(this.code) { + case 401: + message = 'Wrong username or/and password'; + break; + case 404: + message = 'Url not found'; + break; + case 500: + message = 'Server error'; + break; + default: + message = this.code; + } + + Error.call(this, message); + } + CaldavHttpError.prototype = { + __proto__: Error.prototype, + constructor: CaldavHttpError + } + + // Unauthenticated error for + // Google Calendar + function UnauthenticatedError() { + var message = "Wrong username or/and password"; + Error.call(this, message); + } + + UnauthenticatedError.prototype = { + __proto__: Error.prototype, + constructor: UnauthenticatedError + } + + module.exports = { + CaldavHttpError: CaldavHttpError, + UnauthenticatedError: UnauthenticatedError + }; + +}.apply( + this, + (this.Caldav) ? + [Caldav('request/errors'), Caldav] : + [module, require('../caldav')] +)); |