Exception
SugoiJS provides extendable exception (error) class for better error handling.
SugoiJS provides base abstract exception (error) class which can be extended and used for exceptions handling
1
SugoiError:{
2
code:number;
3
message:string;
4
data:Array<any>;
5
}
Copied!
Feel free to extend this class to identify your own errors by:
1
switch(err.constructor.name){
2
case "MySugoiError":
3
//handled error
4
break;
5
default:
6
throw err;
7
}
Copied!
Or by:
1
if( err instanceof MySugoiError){
2
//handled error
3
}else{
4
throw err;
5
}
Copied!
Last modified 3yr ago
Copy link