@candlerip/shared3 0.0.123 → 0.0.125
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
import { ProjectName } from '../../../project/index.js';
|
1
2
|
import { CustomError } from '../type.js';
|
2
3
|
import { Info, Message } from './type.js';
|
3
4
|
export declare const customErrorWorker: (info?: Info) => {
|
4
5
|
addInfo: (info?: Info) => void;
|
5
6
|
composeCustomError: (message: Message, info?: Info) => CustomError;
|
7
|
+
setProjectName: (projectName: ProjectName) => void;
|
6
8
|
};
|
@@ -2,18 +2,29 @@ import { ProjectSingleton } from '../../../project/index.js';
|
|
2
2
|
import { composeCustomError as composeCustomErrorFunc } from '../compose-custom-error/index.js';
|
3
3
|
export const customErrorWorker = (info) => {
|
4
4
|
let _info = info;
|
5
|
+
let _projectName;
|
5
6
|
const addInfo = (info) => {
|
7
|
+
composeInfo(info);
|
8
|
+
};
|
9
|
+
const composeCustomError = (message, info) => {
|
10
|
+
composeInfo(info);
|
11
|
+
return composeCustomErrorFunc(message, _projectName ?? ProjectSingleton.getProjectName(), _info);
|
12
|
+
};
|
13
|
+
const composeInfo = (info) => {
|
14
|
+
if (!_info && !info) {
|
15
|
+
return;
|
16
|
+
}
|
6
17
|
_info = {
|
7
18
|
..._info,
|
8
19
|
...info,
|
9
20
|
};
|
10
21
|
};
|
11
|
-
const
|
12
|
-
|
13
|
-
|
14
|
-
});
|
22
|
+
const setProjectName = (projectName) => {
|
23
|
+
_projectName = projectName;
|
24
|
+
};
|
15
25
|
return {
|
16
26
|
addInfo,
|
17
27
|
composeCustomError,
|
28
|
+
setProjectName,
|
18
29
|
};
|
19
30
|
};
|