Added error handler to web server.
This commit is contained in:
20
src/errors.js
Normal file
20
src/errors.js
Normal 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 };
|
||||
Reference in New Issue
Block a user