Skip to content

Commit

Permalink
refactor: ResponseError Detail -> Details
Browse files Browse the repository at this point in the history
  • Loading branch information
masonkatz committed Mar 4, 2024
1 parent ad365fd commit ee69525
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sifi/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ import (

// ResponseError is the response body for all error responses.
type ResponseError struct {
Code int `json:"code"`
Text string `json:"error"`
Detail []string `json:"detail"`
Code int `json:"code"`
Text string `json:"error"`
Details []string `json:"details"`
}

// NewErrorResponse returns a new ErrorResponse.
func NewErrorResponse(code int, err error, detail ...string) *ResponseError {
return &ResponseError{
Code: code,
Text: err.Error(),
Detail: detail,
Code: code,
Text: err.Error(),
Details: detail,
}
}

// Error implements the error interface for e.
func (e ResponseError) Error() string {
s := fmt.Sprintf("%s (%d) - %s", strings.ToLower(http.StatusText(e.Code)), e.Code, e.Text)
for _, d := range e.Detail {
for _, d := range e.Details {
s += "\n\t" + d
}

Expand Down

0 comments on commit ee69525

Please sign in to comment.