Browse Source

Add NewErrorWithCause()

pull/1780/head
Jae Kwon 7 years ago
parent
commit
bb875303c2
1 changed files with 7 additions and 3 deletions
  1. +7
    -3
      common/errors.go

+ 7
- 3
common/errors.go View File

@ -16,7 +16,11 @@ type Error interface {
} }
func NewError(msg string) Error { 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 { type traceItem struct {
@ -35,10 +39,10 @@ type cmnError struct {
traces []traceItem traces []traceItem
} }
func newError(msg string) *cmnError {
func newError(msg string, cause error) *cmnError {
return &cmnError{ return &cmnError{
msg: msg, msg: msg,
cause: nil,
cause: cause,
traces: nil, traces: nil,
} }
} }


Loading…
Cancel
Save