How to return structured ApiError when extending as a framework #4949
Answered
by
ganigeorgiev
thangngoc89
asked this question in
Q&A
-
I'm trying to return structured error data (at least a machine readable code) in a hook. Here is what I've tried so far: import (
validation "github.com/go-ozzo/ozzo-validation/v4"
)
return apis.NewBadRequestError(
"human readable message",
validation.NewError(
"machine_code",
"machine message"
),
) I could see the nicely formatted "Human Readable Message.". However the |
Beta Was this translation helpful? Give feedback.
Answered by
ganigeorgiev
May 18, 2024
Replies: 1 comment 1 reply
-
The data value must be a return apis.NewBadRequestError("human readable message", validation.Errors{
// field -> error
"machine": validation.NewError("machine_code", "machine message"),
}) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
thangngoc89
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The data value must be a
map[string]validation.Error
(orvalidation.Errors
) in order to be publicly visible, aka. in other words you can try with: