26 lines
476 B
Go
26 lines
476 B
Go
package lemmy
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
// HTTPError represents an error caused by a non-200 HTTP status code
|
|
type HTTPError struct {
|
|
Code int
|
|
}
|
|
|
|
func (he HTTPError) Error() string {
|
|
return fmt.Sprintf("%d %s", he.Code, http.StatusText(he.Code))
|
|
}
|
|
|
|
// Error represents an error returned by the Lemmy API
|
|
type Error struct {
|
|
ErrStr string
|
|
Code int
|
|
}
|
|
|
|
func (le Error) Error() string {
|
|
return fmt.Sprintf("%d %s: %s", le.Code, http.StatusText(le.Code), le.ErrStr)
|
|
}
|