mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user