aboutsummaryrefslogtreecommitdiffstats
path: root/lib/caldav/request/errors.js
blob: c3c166ebb388c0c521e820aa38b5b0f49ae2aca8 (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
41
42
43
44
45
46
47
48
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')]
));