Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

Custom Error Message Class

export class CustomError {
	name: string = '';
	_statusCode: number = 500;
	status: 'error' | 'fail' = 'error';
	stack: string = '';
	isOperational: boolean = true;
	constructor(public message: string, code: number) {
		this.statusCode = code;
		Error.captureStackTrace(this, this.constructor);
	}
	set statusCode(num: number) {
		this.status = num.toString().startsWith('4') ? 'fail' : 'error';
		this._statusCode = num;
	}
	get statusCode() {
		return this._statusCode;
	}
}
//new CustomError(message, statusCode)
Comment

PREVIOUS NEXT
Code Example
Typescript :: Display Popular Posts laravel 
Typescript :: uTorrent Default Download Folder - Linux 
Typescript :: dividing a number into digits typescript 
Typescript :: how to get an object from array of objects in java 
Typescript :: ngx-numeral 
Typescript :: c# ienumerable wrap to know when its compltee 
Typescript :: how t make fireball roblox or lua 
Typescript :: feature counts bioconda 
Typescript :: youtube comments scrape r 
Typescript :: Destructuring props in styled-components 
Typescript :: managed code array too few arguments for class template 
Typescript :: How to loop the jquery formData key object in jqueyr 
Typescript :: Exclude code from hints delphi 7 
Typescript :: sum the digits in c 
Typescript :: How to pass multiple route parameters in Ionic-Angular? 
Typescript :: input adresse ville automatique 
Typescript :: ?In static pages, the contents are fluid and changeable (e.g., rotating banners). 
Typescript :: firewalld list ports redbat 8 
Typescript :: facade design pattern typescript 
Typescript :: hhow to remove elements from java 
Typescript :: Angular/RxJs When should I unsubscribe from `Subscription` 
Typescript :: what are modules in typescript 
Typescript :: ts in r 
Typescript :: how to set up vuex with typescript 
Typescript :: consisting either of digits only or Latin letters 
Typescript :: keep footer after all elements react 
Typescript :: flutter firestore collection snapshots queries tutorial 
Typescript :: box collision detection 
Typescript :: MAYA Simulation of how light propagates in an environment known as: 
Typescript :: how to call an action from another action in redux 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =