You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue description
Usually, you can unmarshal the error returned by a function into the struct it was declared as. Now the issue here is this struct is set as an internal property of the Fiber library, therefore, making it inaccessible to the project where Fiber is used in.
Location of the decoder's Error struct: github.com/gofiber/fiber/v2/internal/go-json/errors
Code snippet
funcParseBody(ctx*fiber.Ctx, bodyinterface{}) *fiber.Error {
// parse request to structiferr:=ctx.BodyParser(body); err!=nil {
// This should parse the error's string into a struct of the errorifjsonErr, ok:=err.(*errors.UnmarshalTypeError); ok {
// use jsonErr to get values from error
} else {
// The error is not an UnmarshalTypeErrorreturnfiber.ErrBadRequest
}
}
returnnil
}
The text was updated successfully, but these errors were encountered:
Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord
Fiber version
Fiber v2.25.0
Issue description
Usually, you can unmarshal the error returned by a function into the struct it was declared as. Now the issue here is this struct is set as an internal property of the Fiber library, therefore, making it inaccessible to the project where Fiber is used in.
Location of the decoder's Error struct:
github.com/gofiber/fiber/v2/internal/go-json/errors
Code snippet
The text was updated successfully, but these errors were encountered: