Skip to content

Commit

Permalink
Rollback: HTTP/2 does not contain status texts
Browse files Browse the repository at this point in the history
  • Loading branch information
fvdm committed Sep 4, 2023
1 parent eb3e4fb commit c0f0be9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion europeana.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ 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 @@ -108,7 +116,8 @@ module.exports = class Europeana {

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

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

0 comments on commit c0f0be9

Please sign in to comment.