diff --git a/faults.go b/faults.go index 1c3fb5e..ff8d6f3 100644 --- a/faults.go +++ b/faults.go @@ -491,7 +491,7 @@ type MissingFailure struct { } func (e *MissingFailure) Error() string { - return "resource not found" + return maybeWrap(e.error, "resource not found").Error() } func (e *MissingFailure) Is(target error) bool { @@ -508,7 +508,7 @@ type PermissionFailure struct { } func (e *PermissionFailure) Error() string { - return "permission denied" + return maybeWrap(e.error, "permission denied").Error() } func (e *PermissionFailure) Is(target error) bool { diff --git a/faults_test.go b/faults_test.go index 3b74e19..431dc30 100644 --- a/faults_test.go +++ b/faults_test.go @@ -508,6 +508,16 @@ func TestErrorMessage(t *testing.T) { err: faults.WithResourceExhausted(cause), wantMsg: "quota failure: underlying issue", }, + { + scenario: "WithNotFound wrapping a cause includes the cause in the message", + err: faults.WithNotFound(cause), + wantMsg: "resource not found: underlying issue", + }, + { + scenario: "WithPermissionDenied wrapping a cause includes the cause in the message", + err: faults.WithPermissionDenied(cause), + wantMsg: "permission denied: underlying issue", + }, } for _, tt := range tests {