Skip to content

Commit

Permalink
UI: Add file name to JSON exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
deribaucourt committed Mar 4, 2024
1 parent 3da5287 commit 98954e3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/src/utils/JSONFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
import fs from 'fs'

export function loadJsonFile (path: string): any {
if (!fs.existsSync(path)) {
return {}
try {
if (!fs.existsSync(path)) {
return {}
}
return JSON.parse(fs.readFileSync(path, 'utf-8'))
} catch (e: any) {
throw new Error(`Error while reading JSON file ${path}: ${e}`)
}
return JSON.parse(fs.readFileSync(path, 'utf-8'))
}

export function saveJsonFile (path: string, json: any): void {
Expand Down

0 comments on commit 98954e3

Please sign in to comment.