Skip to content

Commit 88b6b15

Browse files
committed
throw error while catch a issue
1 parent 4ce0013 commit 88b6b15

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "json-to-js-obj",
3-
"version": "1.0.3",
3+
"version": "1.0.5",
44
"description": "A utility to remove comments from JSON and return javascript object",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

src/utility/json-to-object.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
const jsonPharse = (json: string): any => {
88
try {
9-
9+
1010
if (typeof json !== 'string') throw new Error('argument is not string');
1111

1212
// remove comments
@@ -23,7 +23,8 @@ const jsonPharse = (json: string): any => {
2323
return jsObj;
2424
}
2525
catch (error: any) {
26-
return console.log(`\x1b[31m${error.message}\x1b[0m`)
26+
console.log(`\x1b[31m${error.message}\x1b[0m`);
27+
throw new Error();
2728
}
2829
};
2930

0 commit comments

Comments
 (0)