mirror of
https://github.com/coder/coder.git
synced 2025-07-06 15:41:45 +00:00
chore: create interface for pkgs to return codersdk errors (#18719)
This interface allows it to create rich codersdk errors and pass them up to the `wsbuilder` error handling.
This commit is contained in:
19
coderd/httpapi/httperror/responserror.go
Normal file
19
coderd/httpapi/httperror/responserror.go
Normal file
@ -0,0 +1,19 @@
|
||||
package httperror
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
)
|
||||
|
||||
type Responder interface {
|
||||
Response() (int, codersdk.Response)
|
||||
}
|
||||
|
||||
func IsResponder(err error) (Responder, bool) {
|
||||
var responseErr Responder
|
||||
if errors.As(err, &responseErr) {
|
||||
return responseErr, true
|
||||
}
|
||||
return nil, false
|
||||
}
|
Reference in New Issue
Block a user