2021-01-10 19:52:54 +00:00
|
|
|
package remote
|
2021-01-08 22:43:03 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RequestErrors struct {
|
|
|
|
Errors []RequestError `json:"errors"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type RequestError struct {
|
|
|
|
response *http.Response
|
|
|
|
Code string `json:"code"`
|
|
|
|
Status string `json:"status"`
|
|
|
|
Detail string `json:"detail"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsRequestError(err error) bool {
|
|
|
|
_, ok := err.(*RequestError)
|
|
|
|
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the error response in a string form that can be more easily consumed.
|
|
|
|
func (re *RequestError) Error() string {
|
|
|
|
c := 0
|
|
|
|
if re.response != nil {
|
|
|
|
c = re.response.StatusCode
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("Error response from Panel: %s: %s (HTTP/%d)", re.Code, re.Detail, c)
|
|
|
|
}
|
|
|
|
|
2021-02-02 04:59:17 +00:00
|
|
|
type SftpInvalidCredentialsError struct {
|
2021-01-08 22:43:03 +00:00
|
|
|
}
|
|
|
|
|
2021-02-02 04:59:17 +00:00
|
|
|
func (ice SftpInvalidCredentialsError) Error() string {
|
2021-01-08 22:43:03 +00:00
|
|
|
return "the credentials provided were invalid"
|
|
|
|
}
|