Added error handler to web server.

This commit is contained in:
DebaucheryLibrarian
2021-02-26 19:39:48 +01:00
parent f018735052
commit 0eba0461c9
5 changed files with 55 additions and 1 deletions

20
src/errors.js Normal file
View File

@@ -0,0 +1,20 @@
'use strict';
class HttpError extends Error {
constructor(message, httpCode, friendlyMessage, data) {
super(message);
this.name = 'HttpError';
this.httpCode = httpCode;
if (friendlyMessage) {
this.friendlyMessage = friendlyMessage;
}
if (data) {
this.data = data;
}
}
}
module.exports = { HttpError };