From bb875303c29d675c0934bfae026642a8c2a29358 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Sat, 17 Mar 2018 14:42:08 +0100 Subject: [PATCH] Add NewErrorWithCause() --- common/errors.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/common/errors.go b/common/errors.go index 4a15d0ee6..4e2591a9f 100644 --- a/common/errors.go +++ b/common/errors.go @@ -16,7 +16,11 @@ type Error interface { } func NewError(msg string) Error { - return newError(msg) + return newError(msg, nil) +} + +func NewErrorWithCause(cause error, msg string) Error { + return newError(msg, cause) } type traceItem struct { @@ -35,10 +39,10 @@ type cmnError struct { traces []traceItem } -func newError(msg string) *cmnError { +func newError(msg string, cause error) *cmnError { return &cmnError{ msg: msg, - cause: nil, + cause: cause, traces: nil, } }