Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
profawxhawk committed Mar 3, 2024
1 parent a39543d commit 153e555
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions v3/integrations/nrpkgerrors/nrkpgerrors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestWrappedStackTrace(t *testing.T) {
{Error: theta(basicError{}), ExpectTopFrame: ""},
{Error: basicNRError(basicError{}), ExpectTopFrame: ""},
{Error: withAttributes(basicError{}), ExpectTopFrame: "", ExpectAttributes: map[string]interface{}{"testAttribute": 1, "foo": 2}},
{Error: nil, ExpectTopFrame: ""},
}

for idx, tc := range testcases {
Expand Down Expand Up @@ -117,6 +118,7 @@ func TestWrappedErrorClass(t *testing.T) {
{Error: alpha(basicError{}), ExpectClass: "nrpkgerrors.basicError"},
{Error: wrapWithClass(basicError{}, "zip"), ExpectClass: "zip"},
{Error: alpha(wrapWithClass(basicError{}, "zip")), ExpectClass: "nrpkgerrors.basicError"},
{Error: nil, ExpectClass: "*errors.fundamental"},
}

for idx, tc := range testcases {
Expand Down
6 changes: 5 additions & 1 deletion v3/integrations/nrpkgerrors/nrpkgerrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ var (
// type.
func Wrap(e error) error {
if e == nil {
return errNilError
return newrelic.Error{
Message: errNilError.Error(),
Class: errorClass(errNilError),
Stack: stackTrace(errNilError),
}
}

attributes := make(map[string]interface{})
Expand Down

0 comments on commit 153e555

Please sign in to comment.