4da080e769
specify more concrete error cases to make their way back up the stack. Over time there is probably a cleaner way of doing this, but that's looking like a more massive rewrite and this solves some issues in the meantime. Use a CodedError to return a more concrete HTTP return code for operations you want to do so. Returning a regular error leaves the existing behavior in place.
25 lines
332 B
Go
25 lines
332 B
Go
package logical
|
|
|
|
type HTTPCodedError interface {
|
|
Error() string
|
|
Code() int
|
|
}
|
|
|
|
func CodedError(c int, s string) HTTPCodedError {
|
|
return &codedError{s,c}
|
|
}
|
|
|
|
type codedError struct {
|
|
s string
|
|
code int
|
|
}
|
|
|
|
func (e *codedError) Error() string {
|
|
return e.s
|
|
}
|
|
|
|
func (e *codedError) Code() int {
|
|
return e.code
|
|
}
|
|
|