Skip to content

Commit

Permalink
Fix colerrs pointers/err checks
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling committed May 29, 2023
1 parent c51fe00 commit 4024e2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions internal/colerrs/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ func NewRequestError(statusCode int, wrapped error) *RequestError {
}
}

func (r *RequestError) Error() string {
func (r RequestError) Error() string {
return r.wrapped.Error()
}

func (r *RequestError) Unwrap() error {
func (r RequestError) Unwrap() error {
return r.wrapped
}

func (r *RequestError) StatusCode() int {
func (r RequestError) StatusCode() int {
return r.statusCode
}
5 changes: 3 additions & 2 deletions receiver/otlpreceiver/otlphttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ func handleTraces(resp http.ResponseWriter, req *http.Request, tracesReceiver *t
}

// perhaps it was an HTTP exporter that failed?
if errors.As(err, &colerrs.RequestError{}) {
httpStatus = err.(*colerrs.RequestError).StatusCode()
reqErr := &colerrs.RequestError{}
if errors.As(err, reqErr) {
httpStatus = reqErr.StatusCode()
}

writeError(resp, encoder, err, httpStatus)
Expand Down

0 comments on commit 4024e2f

Please sign in to comment.