Skip to content

Commit c46396a

Browse files
committed
build: migrate error to ts
1 parent e811519 commit c46396a

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

source/error.js renamed to source/error.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
// :copyright: Copyright (c) 2016 ftrack
2-
/**
3-
* Error namespace
4-
* @namespace error
5-
*/
62

73
/**
84
*
@@ -12,15 +8,16 @@
128
* @param {string} name name of error class
139
* @return {CustomError} Custom error object
1410
*/
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;
2214

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+
}
2421

2522
return CustomError;
2623
}

0 commit comments

Comments
 (0)