mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
feat(api): display details in error response (#2228)
This commit is contained in:
parent
a5d6ab0410
commit
887c16c580
1 changed files with 3 additions and 2 deletions
|
@ -16,7 +16,8 @@ type (
|
|||
Err error
|
||||
}
|
||||
errorResponse struct {
|
||||
Err string `json:"err,omitempty"`
|
||||
Err string `json:"err,omitempty"`
|
||||
Details string `json:"details,omitempty"`
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -31,7 +32,7 @@ func writeErrorResponse(rw http.ResponseWriter, err *HandlerError) {
|
|||
log.Printf("http error: %s (err=%s) (code=%d)\n", err.Message, err.Err, err.StatusCode)
|
||||
rw.Header().Set("Content-Type", "application/json")
|
||||
rw.WriteHeader(err.StatusCode)
|
||||
json.NewEncoder(rw).Encode(&errorResponse{Err: err.Message})
|
||||
json.NewEncoder(rw).Encode(&errorResponse{Err: err.Message, Details: err.Err.Error()})
|
||||
}
|
||||
|
||||
// WriteError is a convenience function that creates a new HandlerError before calling writeErrorResponse.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue