Skip to content

Commit

Permalink
Remove error-swallowing try/catch blocks
Browse files Browse the repository at this point in the history
Closes unvt#130
  • Loading branch information
keichan34 committed Dec 15, 2022
1 parent 3a6b5ec commit 82ca79a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ export async function build(
}
}

try {
fs.writeFileSync(destinationPath, style)
} catch (err) {
throw `${destinationPath}: Permission denied`
}
fs.writeFileSync(destinationPath, style)
}

export function buildWatch(
Expand Down
12 changes: 2 additions & 10 deletions src/commands/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ export function convert(source: string, destination: string) {
const style = JSON.parse(lines.join(''))
const destinationPath = getDestinationPath(destination)

try {
writeYaml(destinationPath, style, false)
} catch (err) {
throw `${destinationPath}: Permission denied`
}
writeYaml(destinationPath, style, false)
})
} else {
sourcePath = path.resolve(process.cwd(), source)
Expand All @@ -67,10 +63,6 @@ export function convert(source: string, destination: string) {

const destinationPath = getDestinationPath(destination, sourcePath)

try {
writeYaml(destinationPath, style, false)
} catch (err) {
throw `${destinationPath}: Permission denied`
}
writeYaml(destinationPath, style, false)
}
}
6 changes: 1 addition & 5 deletions src/lib/yaml-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ const writeCompositedYaml = (
stylePath = destinationPath
}

try {
fs.writeFileSync(stylePath, styleYAML)
} catch (err) {
throw `${stylePath}: Permission denied`
}
fs.writeFileSync(stylePath, styleYAML)
}

const writeDecompositedYaml = (
Expand Down

0 comments on commit 82ca79a

Please sign in to comment.