upgrade logger errors

This commit is contained in:
Barry Low committed 2018-10-30 15:19:16 -07:00
1 parent 926788e916
commit 4ae50ab3f2
2 files changed
+22 -1

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
export class AuthentificationError extends Error {
code = 401
message = 'Autentification not found, you have to be authentificated to perform this action'
}
export class DatabaseError extends Error {
code = 404
message = 'Ressource not found : ' + this.message
}
export class WrongArgumentsError extends Error {
code = 400
message = 'Wrong arguments : ' + this.message
}
export class ServiceUnavailableError extends Error {
code = 503
message = 'At least one service is unresponding ' + this.message
}
+3 -1
View File
@@ -1,6 +1,8 @@
import { createLogger, format, transports } from 'winston'
import { inspect } from 'util'
import { AuthentificationError, DatabaseError, WrongArgumentsError, ServiceUnavailableError } from './errors'
class LoggerService {
constructor() {
const winstonTransports = [
@@ -28,4 +30,4 @@ class LoggerService {
}
export const logger = new LoggerService() // Default logger
export { LoggerService }
export { LoggerService, AuthentificationError, DatabaseError, WrongArgumentsError, ServiceUnavailableError }