spotify-web-api-node icon indicating copy to clipboard operation
spotify-web-api-node copied to clipboard

chore: report non-JSON error from API

Open miraclx opened this issue 2 years ago • 0 comments

Certain classes of errors return non-JSON responses, leading to errors like these:

WebapiError: [object Object]
    at _toError (<project>/node_modules/spotify-web-api-node/src/http-manager.js:48:10)
    at <project>/node_modules/spotify-web-api-node/src/http-manager.js:72:25
    at Request.callback (<project>/node_modules/superagent/lib/node/index.js:905:3)
    at IncomingMessage.<anonymous> (<project>/node_modules/superagent/lib/node/index.js:1127:20)
    at Stream.emit (node:events:513:28)
    at Unzip.<anonymous> (<project>/node_modules/superagent/lib/node/unzip.js:53:12)
    at Unzip.emit (node:events:513:28)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  body: {},
  headers: { ... },
  statusCode: 403
}

this patch makes it so we report the textual errors in the case that there are any.

WebapiError: User not registered in the Developer Dashboard
    at _toError (<project>/node_modules/spotify-web-api-node/src/http-manager.js:48:10)
    at <project>/node_modules/spotify-web-api-node/src/http-manager.js:72:25
    at Request.callback (<project>/node_modules/superagent/lib/node/index.js:905:3)
    at IncomingMessage.<anonymous> (<project>/node_modules/superagent/lib/node/index.js:1127:20)
    at Stream.emit (node:events:513:28)
    at Unzip.<anonymous> (<project>/node_modules/superagent/lib/node/unzip.js:53:12)
    at Unzip.emit (node:events:513:28)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  body: {},
  headers: { ... },
  statusCode: 403
}

miraclx avatar Apr 03 '23 04:04 miraclx