UNPKG

@overture-stack/lyric

Version:
56 lines (55 loc) 1.46 kB
export class BadRequest extends Error { constructor(msg, details) { super(msg); this.name = 'Bad Request'; this.cause = details; } } export class Forbidden extends Error { constructor(msg) { super(msg); this.name = 'Forbidden'; } } export class NotFound extends Error { constructor(msg) { super(msg); this.name = 'Not Found'; } } export class StatusConflict extends Error { constructor(msg) { super(msg); this.name = 'Conflict'; } } export class TSVParseError extends Error { constructor(msg) { super(msg || `TSV file is formatted incorrectly`); this.name = 'Parse Error'; } } export class NotImplemented extends Error { constructor(msg) { super(msg || 'This functionallity is not yet implemented'); this.name = 'Not Implemented'; } } export class ServiceUnavailable extends Error { constructor(msg) { super(msg || 'Server is unable to access the necessary resources to process the request. Please try again later.'); this.name = 'Service unavailable'; } } export class InternalServerError extends Error { constructor(msg) { super(msg || 'Something unexpected happened'); this.name = 'Internal Server Error'; } } export const getErrorMessage = (error) => { if (error instanceof Error) { return error.message; } return String(error); };