Skip to content

Commit

Permalink
Update noaa errors to wrap error
Browse files Browse the repository at this point in the history
  • Loading branch information
poy committed Oct 8, 2016
1 parent 0f27b20 commit 502545e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 2 additions & 1 deletion consumer/async_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package consumer_test

import (
"crypto/tls"
"fmt"
"net/http"
"net/http/httptest"
"sync"
Expand Down Expand Up @@ -936,7 +937,7 @@ var _ = Describe("Consumer (Asynchronous)", func() {
})

func BeRetryable() types.GomegaMatcher {
return BeAssignableToTypeOf(errors.RetryError("some-error"))
return BeAssignableToTypeOf(errors.NewRetryError(fmt.Errorf("some-error")))
}

func createError(message string) *events.Envelope {
Expand Down
10 changes: 7 additions & 3 deletions errors/non_retry_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import "fmt"
// NonRetryError is a type that noaa uses when it encountered an error,
// and is not going to retry the operation. When errors of this type
// are encountered, they should result in a closed connection.
type NonRetryError string
type NonRetryError struct {
Err error
}

// NewNonRetryError constructs a NonRetryError from any error.
func NewNonRetryError(err error) NonRetryError {
return NonRetryError(err.Error())
return NonRetryError{
Err: err,
}
}

// Error implements error.
func (e NonRetryError) Error() string {
return fmt.Sprintf("Please ask your Cloud Foundry Operator to check the platform configuration: %s", string(e))
return fmt.Sprintf("Please ask your Cloud Foundry Operator to check the platform configuration: %s", e.Err.Error())
}
10 changes: 7 additions & 3 deletions errors/retry_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ package errors
// RetryError is a type that noaa uses when it encountered an error,
// but is going to retry the operation. When errors of this type
// are encountered, they should not result in a closed connection.
type RetryError string
type RetryError struct {
Err error
}

// NewRetryError constructs a RetryError from any error.
func NewRetryError(err error) RetryError {
return RetryError(err.Error())
return RetryError{
Err: err,
}
}

// Error implements error.
func (e RetryError) Error() string {
return string(e)
return e.Err.Error()
}

0 comments on commit 502545e

Please sign in to comment.