• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thelinmichael / spotify-web-api-node / #194

07 Dec 2024 10:03PM UTC coverage: 96.978% (-1.3%) from 98.291%
#194

push

travis-ci

Zaptyp
Deprecated some functions (https://developer.spotify.com/blog/2024-11-27-changes-to-the-web-api)

132 of 147 branches covered (89.8%)

7 of 7 new or added lines in 1 file covered. (100.0%)

7 existing lines in 2 files now uncovered.

353 of 364 relevant lines covered (96.98%)

35.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

77.78
/src/response-error.js
1
/* Timeout */
2
class NamedError extends Error {
3
  get name() {
4
    return this.constructor.name;
8✔
5
  }
6
}
7

8
class TimeoutError extends NamedError {
9
  constructor() {
10
    const message =
11
      "A timeout occurred while communicating with Spotify's Web API.";
2✔
12
    super(message);
2✔
13
  }
14
}
15

16
class WebapiRatelimitError extends NamedError {
17
  constructor(body, headers, statusCode) {
UNCOV
18
    const message = `Spotify API rate limit exceeded. Retry after ${headers.get('Retry-After')} seconds`;
×
UNCOV
19
    super(message);
×
UNCOV
20
    this.body = body;
×
UNCOV
21
    this.statusCode = statusCode;
×
22
  }
23
}
24

25
/* Web API Parent and fallback error */
26
class WebapiError extends NamedError {
27
  constructor(body, headers, statusCode, message) {
28
    super(message);
11✔
29
    this.body = body;
11✔
30
    this.headers = headers;
11✔
31
    this.statusCode = statusCode;
11✔
32
  }
33
}
34

35
/**
36
 * Regular Error
37
 * { status : <integer>, message : <string> }
38
 */
39
class WebapiRegularError extends WebapiError {
40
  constructor(body, headers, statusCode) {
41
    const message =
42
      "An error occurred while communicating with Spotify's Web API.\n" +
4✔
43
      'Details: ' +
44
      body.error.message +
45
      '.';
46

47
    super(body, headers, statusCode, message);
4✔
48
  }
49
}
50

51
/**
52
 * Authentication Error
53
 * { error : <string>, error_description : <string> }
54
 */
55
class WebapiAuthenticationError extends WebapiError {
56
  constructor(body, headers, statusCode) {
57
    const message =
58
      "An authentication error occurred while communicating with Spotify's Web API.\n" +
3✔
59
      'Details: ' +
60
      body.error +
61
      (body.error_description ? ' ' + body.error_description + '.' : '.');
3✔
62

63
    super(body, headers, statusCode, message);
3✔
64
  }
65
}
66

67
/**
68
 * Player Error
69
 * { status : <integer>, message : <string>, reason : <string> }
70
 */
71
class WebapiPlayerError extends WebapiError {
72
  constructor(body, headers, statusCode) {
73
    const message =
74
      "An error occurred while communicating with Spotify's Web API.\n" +
2✔
75
      'Details: ' +
76
      body.error.message +
77
      (body.error.reason ? ' ' + body.error.reason + '.' : '.');
2!
78

79
    super(body, headers, statusCode, message);
2✔
80
  }
81
}
82

83
module.exports = {
3✔
84
  WebapiError,
85
  TimeoutError,
86
  WebapiRegularError,
87
  WebapiAuthenticationError,
88
  WebapiPlayerError,
89
  WebapiRatelimitError
90
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc