File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change 1
1
// :copyright: Copyright (c) 2016 ftrack
2
- /**
3
- * Error namespace
4
- * @namespace error
5
- */
6
2
7
3
/**
8
4
*
12
8
* @param {string } name name of error class
13
9
* @return {CustomError } Custom error object
14
10
*/
15
- function errorFactory ( name ) {
16
- function CustomError ( message , errorCode ) {
17
- this . name = name ;
18
- this . message = message ;
19
- this . errorCode = errorCode ;
20
- this . stack = new Error ( ) . stack ;
21
- }
11
+ function errorFactory ( name : string ) {
12
+ class CustomError extends Error {
13
+ errorCode : any ;
22
14
23
- CustomError . prototype = new Error ( ) ;
15
+ constructor ( message : string , errorCode ?: number | string ) {
16
+ super ( message ) ;
17
+ this . name = name ;
18
+ this . errorCode = errorCode ;
19
+ }
20
+ }
24
21
25
22
return CustomError ;
26
23
}
You can’t perform that action at this time.
0 commit comments