Skip to content

Commit d8a3434

Browse files
committed
Include the error context in the error string
1 parent 3084677 commit d8a3434

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

errors.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package vcs
22

3-
import "errors"
3+
import (
4+
"errors"
5+
"fmt"
6+
)
47

58
// The vcs package provides ways to work with errors that hide the underlying
69
// implementation details but make them accessible if needed. For basic errors
@@ -93,7 +96,11 @@ type vcsError struct {
9396

9497
// Error implements the Error interface
9598
func (e *vcsError) Error() string {
96-
return e.s
99+
if e.e == nil {
100+
return e.s
101+
}
102+
103+
return fmt.Sprintf("%s: %v", e.s, e.e)
97104
}
98105

99106
// Original retrieves the underlying implementation specific error.

0 commit comments

Comments
 (0)