Skip to content

How to return structured ApiError when extending as a framework #4949

Answered by ganigeorgiev
thangngoc89 asked this question in Q&A
Discussion options

You must be logged in to vote

The data value must be a map[string]validation.Error (or validation.Errors) in order to be publicly visible, aka. in other words you can try with:

return apis.NewBadRequestError("human readable message", validation.Errors{
    // field -> error
    "machine": validation.NewError("machine_code", "machine message"),
})

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@thangngoc89
Comment options

Answer selected by thangngoc89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants