Skip to content

Commit

Permalink
整理错误处理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
pangdogs committed Oct 19, 2024
1 parent 8b36988 commit 84fc3c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions utils/exception/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ func Errorf(format string, args ...any) error {
}

func Panic(v any) {
panic(Error(v))
_, file, line, _ := runtime.Caller(1)
panic(fmt.Errorf("%v (%s:%d)", v, file, line))
}

func Panicf(format string, args ...any) {
panic(Errorf(format, args...))
_, file, line, _ := runtime.Caller(1)
panic(fmt.Errorf(format+" (%s:%d)", append(args, file, line)...))
}

0 comments on commit 84fc3c4

Please sign in to comment.