Skip to content

WriteErrorCode function always returns 500 code inside JSON payload #128

@davidspiess

Description

@davidspiess

Preflight checklist

Describe the bug

I noticed by using the (h *JSONWriter) WriteErrorCode function, that the header is correctly set, but the JSON response returns a 500 status code and message.

Is this a bug or am i interpreting the purpose of the function wrong?

Reproducing the bug

h.d.Writer().WriteErrorCode(w, r, 401, errors.New("error"))

Response:
Image

Version

v0.10.2

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

None

Additional Context

My workaround right now:

h.d.Writer().WriteError(w, r, herodot.DefaultError{
	CodeField:  401,
	ErrorField: errors.New("error"),
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions