chore: change cli error message handling (#9952)

* chore: add command to easily visualize different errors

* chore: add verbose error printing in cli
This commit is contained in:
Steven Masley
2023-09-29 16:50:23 -05:00
committed by GitHub
parent fa297e1096
commit e9ccb8dc78
5 changed files with 246 additions and 51 deletions
+10
View File
@@ -359,6 +359,8 @@ func ReadBodyAsError(res *http.Response) error {
}
return &Error{
statusCode: res.StatusCode,
method: requestMethod,
url: requestURL,
Response: Response{
Message: fmt.Sprintf("unexpected non-JSON response %q", contentType),
Detail: string(resp),
@@ -414,6 +416,14 @@ func (e *Error) StatusCode() int {
return e.statusCode
}
func (e *Error) Method() string {
return e.method
}
func (e *Error) URL() string {
return e.url
}
func (e *Error) Friendly() string {
var sb strings.Builder
_, _ = fmt.Fprintf(&sb, "%s. %s", strings.TrimSuffix(e.Message, "."), e.Helper)