1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-08 20:41:57 +00:00
This commit is contained in:
Gerasimos (Makis) Maropoulos
2023-12-30 13:03:01 +02:00
parent efe953583a
commit c80c5903ab
4 changed files with 77 additions and 17 deletions

View File

@@ -152,6 +152,20 @@ func HandleError(ctx *context.Context, err error) bool {
//
// This method MUST be called on initialization, before HTTP server starts as
// the internal map is not protected by mutex.
//
// Example Code:
//
// errors.InvalidArgument.MapErrorFunc(func(err error) error {
// stripeErr, ok := err.(*stripe.Error)
// if !ok {
// return nil
// }
//
// return &errors.Error{
// Message: stripeErr.Msg,
// Details: stripeErr.DocURL,
// }
// })
func (e ErrorCodeName) MapErrorFunc(fn func(error) error) {
errorFuncCodeMap[e] = append(errorFuncCodeMap[e], fn)
}