Skip to content

Commit

Permalink
Refactor: Removed generic errors
Browse files Browse the repository at this point in the history
The fetch lib already contains them all
  • Loading branch information
fvdm committed Sep 4, 2023
1 parent 80d8264 commit eb3e4fb
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions europeana.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ module.exports = class Europeana {
wskey,
timeout,
};

this._errors = {
400: 'The request sent by the client was syntactically incorrect',
401: 'Authentication credentials were missing or authentication failed.',
404: 'The requested record was not found.',
429: 'The request could be served because the application has reached its usage limit.',
500: 'Internal Server Error. Something has gone wrong, please report to us.',
};
}


Expand Down Expand Up @@ -116,8 +108,7 @@ module.exports = class Europeana {

// HTML error
if (body.match (/^</)) {
const msg = this._errors[res.status] || res.statusText;
const error = new Error (`API error: ${msg}`);
const error = new Error (`API error: ${res.statusText}`);

error.code = res.status;
throw error;
Expand Down

0 comments on commit eb3e4fb

Please sign in to comment.