protonmail: export ApiError
This commit is contained in:
parent
ed67f2a3f5
commit
dea3ab3106
|
@ -24,8 +24,10 @@ type resp struct {
|
||||||
|
|
||||||
func (r *resp) Err() error {
|
func (r *resp) Err() error {
|
||||||
if err := r.apiError; err != nil {
|
if err := r.apiError; err != nil {
|
||||||
err.code = r.Code
|
return &ApiError{
|
||||||
return err
|
Code: r.Code,
|
||||||
|
Message: err.Message,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -35,12 +37,16 @@ type maybeError interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type apiError struct {
|
type apiError struct {
|
||||||
code int // populated by resp
|
|
||||||
Message string `json:"Error"`
|
Message string `json:"Error"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (err apiError) Error() string {
|
type ApiError struct {
|
||||||
return fmt.Sprintf("[%v] %v", err.code, err.Message)
|
Code int
|
||||||
|
Message string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err *ApiError) Error() string {
|
||||||
|
return fmt.Sprintf("[%v] %v", err.Code, err.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client is a ProtonMail API client.
|
// Client is a ProtonMail API client.
|
||||||
|
|
Loading…
Reference in New Issue