add tests, move CustomError to common, fix casting

This commit is contained in:
Matteo Pagliazzi
2016-03-03 00:16:28 +01:00
parent 05b6e25c28
commit 80f791c86b
11 changed files with 260 additions and 42 deletions
+8
View File
@@ -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);
}
}
+9
View File
@@ -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.';
}
}