From aad1925a1cfb2f19f18dfae555caff4175c69a55 Mon Sep 17 00:00:00 2001 From: tursom Date: Fri, 21 May 2021 11:18:56 +0800 Subject: [PATCH] update NewRuntimeException --- exceptions/RuntimeException.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/exceptions/RuntimeException.go b/exceptions/RuntimeException.go index f2b3055..6bebe0d 100644 --- a/exceptions/RuntimeException.go +++ b/exceptions/RuntimeException.go @@ -13,7 +13,7 @@ type RuntimeException struct { cause Exception } -func NewRuntimeException(message, exceptionMessage string, getStackTrace bool, cause Exception) RuntimeException { +func NewRuntimeException(message, exceptionMessage string, getStackTrace bool, cause interface{}) RuntimeException { var stackTrace []StackTrace = nil if getStackTrace { stackTrace = GetStackTrace() @@ -23,11 +23,17 @@ func NewRuntimeException(message, exceptionMessage string, getStackTrace bool, c exceptionMessage = "exception caused:" } + var causeException Exception = nil + switch cause.(type) { + case Exception: + causeException = cause.(Exception) + } + return RuntimeException{ message: message, exceptionMessage: exceptionMessage, stackTrace: stackTrace, - cause: cause, + cause: causeException, } }