Skip to content
This repository was archived by the owner on May 9, 2026. It is now read-only.

chore: report non-JSON error from API#484

Open
miraclx wants to merge 1 commit into
thelinmichael:masterfrom
miraclx:miraclx/proper-error
Open

chore: report non-JSON error from API#484
miraclx wants to merge 1 commit into
thelinmichael:masterfrom
miraclx:miraclx/proper-error

Conversation

@miraclx
Copy link
Copy Markdown

@miraclx miraclx commented Apr 3, 2023

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
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant