go-lemmy/types/types.go

28 lines
463 B
Go
Raw Normal View History

2022-12-10 17:17:16 +00:00
package types
import (
"fmt"
"net/http"
)
type LemmyResponse struct {
Error Optional[string] `json:"error,omitempty" url:"error,omitempty"`
}
type HTTPError struct {
Code int
}
func (he HTTPError) Error() string {
return fmt.Sprintf("%d %s", he.Code, http.StatusText(he.Code))
}
type LemmyError struct {
ErrStr string
Code int
}
func (le LemmyError) Error() string {
return fmt.Sprintf("%d %s: %s", le.Code, http.StatusText(le.Code), le.ErrStr)
}