errors/types.go: add a new UnprocessableEntityError
To indicate that we have encountered an HTTP 422, let's introduce a new sentinel type to do just that. It will be instantiated and returned in a subsequent commit from tq/basic_upload.go, and then caught down in tq/transfer_queue.go.
This commit is contained in:
parent
938df5c47f
commit
013c02d010
@ -127,6 +127,20 @@ func IsDownloadDeclinedError(err error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsDownloadDeclinedError indicates that the upload operation failed because of
|
||||
// an HTTP 422 response code.
|
||||
func IsUnprocessableEntityError(err error) bool {
|
||||
if e, ok := err.(interface {
|
||||
UnprocessableEntityError() bool
|
||||
}); ok {
|
||||
return e.UnprocessableEntityError()
|
||||
}
|
||||
if parent := parentOf(err); parent != nil {
|
||||
return IsUnprocessableEntityError(parent)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsRetriableError indicates the low level transfer had an error but the
|
||||
// caller may retry the operation.
|
||||
func IsRetriableError(err error) bool {
|
||||
@ -321,6 +335,20 @@ func NewDownloadDeclinedError(err error, msg string) error {
|
||||
return downloadDeclinedError{newWrappedError(err, msg)}
|
||||
}
|
||||
|
||||
// Definitions for IsUnprocessableEntityError()
|
||||
|
||||
type unprocessableEntityError struct {
|
||||
*wrappedError
|
||||
}
|
||||
|
||||
func (e unprocessableEntityError) UnprocessableEntityError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func NewUnprocessableEntityError(err error) error {
|
||||
return unprocessableEntityError{newWrappedError(err, "")}
|
||||
}
|
||||
|
||||
// Definitions for IsRetriableError()
|
||||
|
||||
type retriableError struct {
|
||||
|
Loading…
Reference in New Issue
Block a user