diff --git a/recorder/recorder.go b/recorder/recorder.go index 6ffc34a..dc890d1 100644 --- a/recorder/recorder.go +++ b/recorder/recorder.go @@ -29,6 +29,7 @@ import ( "bufio" "bytes" "errors" + "fmt" "io" "net/http" "net/http/httputil" @@ -210,7 +211,7 @@ func NewWithOptions(opts *Options) (*Recorder, error) { rec.cassette = c return rec, nil case opts.Mode == ModeReplayOnly && !cassetteExists: - return nil, cassette.ErrCassetteNotFound + return nil, fmt.Errorf("%w: %s", cassette.ErrCassetteNotFound, cassetteFile) case opts.Mode == ModeReplayOnly && cassetteExists: c, err := cassette.Load(opts.CassetteName) if err != nil { diff --git a/recorder/recorder_test.go b/recorder/recorder_test.go index eb8018c..1deb0d4 100644 --- a/recorder/recorder_test.go +++ b/recorder/recorder_test.go @@ -28,6 +28,7 @@ package recorder_test import ( "bytes" "context" + "errors" "fmt" "io" "net/http" @@ -238,7 +239,7 @@ func TestReplayOnlyModeFailsWithMissingCassette(t *testing.T) { Mode: recorder.ModeReplayOnly, } _, err := recorder.NewWithOptions(opts) - if err != cassette.ErrCassetteNotFound { + if !errors.Is(err, cassette.ErrCassetteNotFound) { t.Fatalf("expected cassette.ErrCassetteNotFound, got %v", err) } }