Skip to content

Commit

Permalink
Remove error-swallowing try/catch blocks (#139)
Browse files Browse the repository at this point in the history
Closes #130
  • Loading branch information
keichan34 committed Dec 20, 2022
1 parent a207fbb commit f6f0ced
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 26 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)
}
}
8 changes: 2 additions & 6 deletions src/lib/build-sprite.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateSprite } from '@unvt/sprite-one'
const path = require('path')
import path from 'path'

export async function buildSprite(
svgPath: string,
Expand All @@ -8,10 +8,6 @@ export async function buildSprite(
): Promise<void> {
const pxRatios = [1, 2]
const outPath = path.join(publicPath, iconSlug)
try {
await generateSprite(outPath, [svgPath], pxRatios)
} catch (error) {
throw error
}
await generateSprite(outPath, [svgPath], pxRatios)
return
}
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 f6f0ced

Please sign in to comment.