mirror of
https://github.com/aykhans/dodo.git
synced 2025-09-05 10:43:37 +00:00
Add config file support to CLI parser
Add -f/--config-file flag for loading YAML configs from local or remote sources. Fix error handling to return unmatched errors.
This commit is contained in:
@@ -17,7 +17,7 @@ type CustomError struct {
|
||||
Message string
|
||||
}
|
||||
|
||||
func (e *CustomError) Error() string {
|
||||
func (e CustomError) Error() string {
|
||||
return fmt.Sprintf("custom error %d: %s", e.Code, e.Message)
|
||||
}
|
||||
|
||||
@@ -91,16 +91,15 @@ func TestHandleError(t *testing.T) {
|
||||
|
||||
t.Run("HandleError with no matching handler", func(t *testing.T) {
|
||||
err := errors.New("unhandled error")
|
||||
handled, result := HandleError(err,
|
||||
handled, _ := HandleError(err,
|
||||
OnSentinelError(io.EOF, func(e error) error {
|
||||
return nil
|
||||
}),
|
||||
OnCustomError(func(e *CustomError) error {
|
||||
OnCustomError(func(e CustomError) error {
|
||||
return nil
|
||||
}),
|
||||
)
|
||||
assert.False(t, handled)
|
||||
assert.NoError(t, result)
|
||||
})
|
||||
|
||||
t.Run("HandleError with multiple matchers first match wins", func(t *testing.T) {
|
||||
@@ -352,9 +351,8 @@ func TestErrorMatcherEdgeCases(t *testing.T) {
|
||||
}
|
||||
|
||||
err := errors.New("test error")
|
||||
handled, result := HandleError(err, matcher)
|
||||
handled, _ := HandleError(err, matcher)
|
||||
assert.False(t, handled)
|
||||
assert.NoError(t, result)
|
||||
})
|
||||
|
||||
t.Run("Handler that panics", func(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user