Skip to content

Commit

Permalink
Refine error handling behavior
Browse files Browse the repository at this point in the history
so that exit 1 happens as long as error is non-nil
  • Loading branch information
meatballhat committed Jul 24, 2016
1 parent 8ae5b3d commit e968881
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## [Unreleased]
### Added
- Flag type code generation via `go generate`
- Write to stderr and exit 1 if action returns non-nil error

### Changed
- Raise minimum tested/supported Go version to 1.2+
Expand Down
2 changes: 1 addition & 1 deletion errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ func HandleExitCoder(err error) {

if err.Error() != "" {
fmt.Fprintln(ErrWriter, err)
OsExiter(1)
}
OsExiter(1)
}
4 changes: 2 additions & 2 deletions errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestHandleExitCoder_ErrorWithoutMessage(t *testing.T) {
err := errors.New("")
HandleExitCoder(err)

expect(t, exitCode, 0)
expect(t, called, false)
expect(t, exitCode, 1)
expect(t, called, true)
expect(t, ErrWriter.(*bytes.Buffer).String(), "")
}

0 comments on commit e968881

Please sign in to comment.