From 6cb7cfb22b99c8335eb3782d398e2f94431572db Mon Sep 17 00:00:00 2001 From: rozturac Date: Wed, 12 Jan 2022 18:34:26 +0300 Subject: [PATCH] bug-fix --- functions.go | 3 ++- go.mod | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/functions.go b/functions.go index d6bf144..94acb15 100644 --- a/functions.go +++ b/functions.go @@ -34,7 +34,8 @@ func getErrorCode() string { frames := runtime.CallersFrames(rpc) frame, _ := frames.Next() if frame.Func != nil && strings.Contains(frame.Function, "Error") { - return strings.Split(frame.Function, ".")[2] + list := strings.Split(frame.Function, ".") + return list[len(list)-1] } else { return "CustomError" } diff --git a/go.mod b/go.mod index 4c00e9a..d95d9ce 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module github.com/rozturac/cerror go 1.16 -require github.com/labstack/echo/v4 v4.6.1 // indirect +require github.com/labstack/echo/v4 v4.6.1