Skip to content

Commit

Permalink
error: remove pointer receiver from Write
Browse files Browse the repository at this point in the history
Otherwise it can't be chained after WithMessage
  • Loading branch information
tulir committed Sep 12, 2024
1 parent 012aed9 commit 36ef69b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions bridgev2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func (re RespError) Is(err error) bool {
return errors.Is(err, mautrix.RespError(re))
}

func (re *RespError) Write(w http.ResponseWriter) {
(*mautrix.RespError)(re).Write(w)
func (re RespError) Write(w http.ResponseWriter) {
mautrix.RespError(re).Write(w)
}

func (re RespError) WithMessage(msg string, args ...any) RespError {
Expand Down
4 changes: 2 additions & 2 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ func (e *RespError) MarshalJSON() ([]byte, error) {
return json.Marshal(data)
}

func (e *RespError) Write(w http.ResponseWriter) {
func (e RespError) Write(w http.ResponseWriter) {
statusCode := e.StatusCode
if statusCode == 0 {
statusCode = http.StatusInternalServerError
}
exhttp.WriteJSONResponse(w, statusCode, e)
exhttp.WriteJSONResponse(w, statusCode, &e)
}

func (e RespError) WithMessage(msg string, args ...any) RespError {
Expand Down

0 comments on commit 36ef69b

Please sign in to comment.