@lakutata/core 1.0.55 → 1.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/plugins/JSON.ts +4 -4
- package/src/tests/Main.spec.ts +4 -2
package/package.json
CHANGED
package/src/plugins/JSON.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {Plugin} from '../base/Plugin'
|
|
2
2
|
import {JSONParserV2} from 'json-helpers'
|
|
3
3
|
import {Exception} from '../base/abstracts/Exception'
|
|
4
|
-
import
|
|
4
|
+
import json5 from 'json5'
|
|
5
5
|
|
|
6
6
|
declare module '../Core' {
|
|
7
7
|
interface Application {
|
|
@@ -23,7 +23,7 @@ JSONParserV2.formatter<Exception | Error>({
|
|
|
23
23
|
objectConstructor: (Error as unknown) as ObjectConstructor,
|
|
24
24
|
serialize: (t: Exception | Error) => {
|
|
25
25
|
if (t instanceof Exception) {
|
|
26
|
-
return
|
|
26
|
+
return json5.stringify({
|
|
27
27
|
isException: true,
|
|
28
28
|
appId: t.appId,
|
|
29
29
|
appName: t.appName,
|
|
@@ -33,7 +33,7 @@ JSONParserV2.formatter<Exception | Error>({
|
|
|
33
33
|
stack: t.stack
|
|
34
34
|
})
|
|
35
35
|
} else {
|
|
36
|
-
return
|
|
36
|
+
return json5.stringify({
|
|
37
37
|
isException: false,
|
|
38
38
|
name: t.name,
|
|
39
39
|
message: t.message,
|
|
@@ -42,7 +42,7 @@ JSONParserV2.formatter<Exception | Error>({
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
unserialize: (data: string) => {
|
|
45
|
-
const parsedErrorObject =
|
|
45
|
+
const parsedErrorObject = json5.parse(data)
|
|
46
46
|
if (parsedErrorObject.isException) {
|
|
47
47
|
const unSerializeException = class extends ParseException {
|
|
48
48
|
public get name(): string {
|
package/src/tests/Main.spec.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {TestComponent1} from './components/TestComponent1'
|
|
|
6
6
|
import {
|
|
7
7
|
Application,
|
|
8
8
|
BaseObject,
|
|
9
|
-
createApp,
|
|
9
|
+
createApp, Exception,
|
|
10
10
|
FatalException, Formatter,
|
|
11
11
|
getApp,
|
|
12
12
|
IApplicationConfig,
|
|
@@ -158,7 +158,9 @@ import {TestException} from './exceptions/TestException'
|
|
|
158
158
|
await app.Processes.destroy(TestProcess)
|
|
159
159
|
const excep = new TestException('hhhh')
|
|
160
160
|
const ssss = app.JSON.stringify(excep)
|
|
161
|
-
|
|
161
|
+
const ssssParsed = app.JSON.parse(ssss)
|
|
162
|
+
console.log(ssssParsed)
|
|
163
|
+
console.log('Is parsed object instance of Exception:', ssssParsed instanceof Exception)
|
|
162
164
|
app.Shell.exec('echo "hello world!!!!!"')
|
|
163
165
|
} catch (e) {
|
|
164
166
|
console.error(e)
|