Skip to content

Commit 83ace21

Browse files
committed
Improved logging for stringify and parse
1 parent 7019fca commit 83ace21

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
- uses: actions/checkout@v4
1919
- run: docker pull adminer
2020
- run: docker pull postgres
21+
- run: npm i -g @angular/cli@18 @loopback/cli@6 @nestjs/cli@11
2122
- run: npm ci
2223
- run: npm run build
2324
- run: npm run test

src/encapsulation/json.utilities.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,23 @@ export abstract class JsonUtilities {
2020
return json5.parse(value);
2121
}
2222
catch (error) {
23-
throw new Error(`Could not parse value:\n ${this.stringify(value)}\n${error}`);
23+
throw new Error(`Could not parse value:\n ${value}\n${error}`);
2424
}
2525
}
2626

2727
/**
2828
* Stringifies the given value into a json string.
2929
* @param value - The value to stringify.
3030
* @returns The json string, formatted with 4 spaces.
31+
* @throws
3132
*/
3233
static stringify<T>(value: T): string {
33-
return JSON.stringify(value, undefined, this.indent);
34+
try {
35+
return JSON.stringify(value, undefined, this.indent);
36+
}
37+
catch (error) {
38+
throw new Error(`Could not stringify value:\n ${value}\n${error}`);
39+
}
3440
}
3541

3642
/**

0 commit comments

Comments
 (0)