Skip to content

Commit

Permalink
feat: more granular error handling on save json file
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Nov 5, 2024
1 parent 78bc3ae commit b0deb44
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/commands/pull-languages/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,21 @@ export const saveLanguagesToFile = async (space: string, internationalizationOpt
await access(resolvedPath, constants.F_OK)
}
catch {
await mkdir(resolvedPath, { recursive: true })
try {
await mkdir(resolvedPath, { recursive: true })
}
catch (mkdirError) {
handleFileSystemError('mkdir', mkdirError as Error)
return // Exit early if the directory creation fails
}
}

return await writeFile(filePath, data, {
mode: 0o600,
})
try {
await writeFile(filePath, data, { mode: 0o600 })
}
catch (writeError) {
handleFileSystemError('write', writeError as Error)
}
}
catch (error) {
handleFileSystemError('write', error as Error)
Expand Down

0 comments on commit b0deb44

Please sign in to comment.