From de50ffca8bec9f2c57fc9d41bd167fc0b23ab832 Mon Sep 17 00:00:00 2001 From: tursom Date: Fri, 21 May 2021 13:52:31 +0800 Subject: [PATCH] update NewRuntimeException --- exceptions/Exception.go | 1 + exceptions/RuntimeException.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/exceptions/Exception.go b/exceptions/Exception.go index 484bade..aab0937 100644 --- a/exceptions/Exception.go +++ b/exceptions/Exception.go @@ -80,5 +80,6 @@ func Print(err error) { err.(Exception).PrintStackTrace() default: _, _ = fmt.Fprintln(os.Stderr, err) + PrintStackTraceByArray(os.Stderr, GetStackTrace()) } } diff --git a/exceptions/RuntimeException.go b/exceptions/RuntimeException.go index 3184b3b..5bcfb01 100644 --- a/exceptions/RuntimeException.go +++ b/exceptions/RuntimeException.go @@ -14,6 +14,14 @@ type RuntimeException struct { cause Exception } +func Package(err error) *RuntimeException { + if err == nil { + return nil + } + runtimeException := NewRuntimeException(err, "", true, err) + return &runtimeException +} + func NewRuntimeException(message interface{}, exceptionMessage string, getStackTrace bool, cause interface{}) RuntimeException { var stackTrace []StackTrace = nil if getStackTrace {