add tests, move CustomError to common, fix casting
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// Base class for custom application errors
|
||||
// It extends Error and capture the stack trace
|
||||
export default class CustomError extends Error {
|
||||
constructor () {
|
||||
super();
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import CustomError from './customError';
|
||||
|
||||
export class NotAuthorized extends CustomError {
|
||||
constructor (customMessage) {
|
||||
super();
|
||||
this.name = this.constructor.name;
|
||||
this.message = customMessage || 'Not authorized.';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user