Skip to content

Commit

Permalink
fix(api): error messages (#58)
Browse files Browse the repository at this point in the history
* feat(api): generic error messages, improved. use `error.name` on the frontend for glean
  • Loading branch information
argl authored Aug 5, 2024
1 parent fa09305 commit efe3ea3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
14 changes: 1 addition & 13 deletions src/api/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,8 @@ export class InvalidHostNameLookupError extends AppError {
* @param {string} hostname
*/
constructor(hostname) {
super(`${hostname} can not be resolved`);
super(`${hostname} cannot be resolved`);
this.name = "invalid-hostname-lookup";
this.statusCode = STATUS_CODES.unprocessableEntity;
}
}

export class RescanTooSoonError extends AppError {
/**
*
* @param {string} hostname
*/
constructor(hostname) {
super(`${hostname} is on temporary cooldown'`);
this.name = "rescan-attempt-too-soon";
this.statusCode = STATUS_CODES.badRequest;
}
}
2 changes: 1 addition & 1 deletion test/apiv2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ describeOrSkip("API V2", function () {
assert.equal(r.error, "invalid-hostname-lookup");
assert.equal(
r.message,
"www.somethingorother1234.mozilla.net can not be resolved"
"www.somethingorother1234.mozilla.net cannot be resolved"
);
}).timeout(6000);

Expand Down

0 comments on commit efe3ea3

Please sign in to comment.