From d8a343481a4d07c96dab32225665c6f8a93be9ad Mon Sep 17 00:00:00 2001 From: Robert Bittle Date: Sat, 15 Jul 2017 19:22:51 -0400 Subject: [PATCH] Include the error context in the error string --- errors.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/errors.go b/errors.go index be70970..b1eb464 100644 --- a/errors.go +++ b/errors.go @@ -1,6 +1,9 @@ package vcs -import "errors" +import ( + "errors" + "fmt" +) // The vcs package provides ways to work with errors that hide the underlying // implementation details but make them accessible if needed. For basic errors @@ -93,7 +96,11 @@ type vcsError struct { // Error implements the Error interface func (e *vcsError) Error() string { - return e.s + if e.e == nil { + return e.s + } + + return fmt.Sprintf("%s: %v", e.s, e.e) } // Original retrieves the underlying implementation specific error.