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/calendar_home.js | |
parent | 84c07224a04189d42abbcd2dbfaf541fa53a90ff (diff) | |
download | jsCalDAV-b74223999c5a240306132704177eb9cbb1dc9143.tar.gz |
error handler
a
error-handling
a
err
Diffstat (limited to 'lib/caldav/request/calendar_home.js')
-rw-r--r-- | lib/caldav/request/calendar_home.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/caldav/request/calendar_home.js b/lib/caldav/request/calendar_home.js index 5ededb5..24b27bc 100644 --- a/lib/caldav/request/calendar_home.js +++ b/lib/caldav/request/calendar_home.js @@ -1,5 +1,7 @@ (function(module, ns) { + var Errors = ns.require('request/errors'); + /** * Creates a propfind request. * @@ -71,8 +73,15 @@ if (!principal) { principal = findProperty('principal-URL', data, true); } - - callback(null, principal); + + if ('unauthenticated' in principal) { + callback(new Errors.UnauthenticatedError()); + } else if (principal.href){ + callback(null, principal.href); + } else { + callback(new Errors.CaldavHttpError(404)); + } + }); }, @@ -109,7 +118,7 @@ self._findPrincipal(self.url, function(err, url) { if (!url) { - callback(new Error('Cannot resolve principal url')); + callback(err); return; } |