Skip to content

Commit

Permalink
Cleaned up error ILSpy error code with a switch statement.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-fox committed Jul 19, 2020
1 parent 9ba391a commit 17355f3
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions cmd/finley/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,21 @@ func main() {
filePath: info.FilePath,
finalOutputDirPath: finalOutputDirPath,
})
if err != nil {
if _, ok := err.(*ilspyError); ok {
if *noIlspyErrors {
return err
}
ioutil.WriteFile(filepath.Join(finalOutputDirPath, "decompile-failure.log"),
[]byte(err.Error()),
0600)
if *verbose {
log.Printf("[warn] %s", err.Error())
}
return nil
switch err.(type) {
case nil:
// Keep going.
case *ilspyError:
if *noIlspyErrors {
return err
}
ioutil.WriteFile(filepath.Join(finalOutputDirPath, "decompile-failure.log"),
[]byte(err.Error()),
0600)
if *verbose {
log.Printf("[warn] %s", err.Error())
}
return nil
default:
return fmt.Errorf("failed to decompile '%s' - %s",
info.FilePath, err.Error())
}
Expand Down Expand Up @@ -266,7 +268,7 @@ func decompileNETFile(info decompileNETInfo) error {
raw, err := exec.Command(info.ilspycmdPath, info.filePath, "-p", "-o", info.finalOutputDirPath).CombinedOutput()
if err != nil {
return &ilspyError{
err: fmt.Sprintf("failed to decompile .NET file '%s' - %s - %s",
err: fmt.Sprintf("failed to decompile file '%s' - %s - %s",
info.filePath, err.Error(), raw),
}
}
Expand Down

0 comments on commit 17355f3

Please sign in to comment.