enbas/internal/client/errors.go
Dan Anglin 3d20adfa57
chore: REUSE.toml
- Replace .reuse/dep5 with the new REUSE.toml file.
- Add licensing information to REUSE.toml and remove the licensing
  headers from the source files.
2024-08-01 04:01:38 +01:00

32 lines
620 B
Go

package client
import "fmt"
type ResponseError struct {
StatusCode int
Message string
MessageDecodeErr error
}
func (e ResponseError) Error() string {
if e.MessageDecodeErr != nil {
return fmt.Sprintf(
"received HTTP code %d from the instance but was unable to decode the error message: %v",
e.StatusCode,
e.MessageDecodeErr,
)
}
if e.Message == "" {
return fmt.Sprintf(
"received HTTP code %d from the instance but no error message was provided",
e.StatusCode,
)
}
return fmt.Sprintf(
"message received from the instance: (%d) %q",
e.StatusCode,
e.Message,
)
}