From: Marc Abramowitz Date: Thu, 19 Dec 2013 21:55:19 +0000 (-0800) Subject: Nicer error for can't overwrite existing cassette X-Git-Tag: v0.6.0~4 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=41f5fce895b93bb3956ec65c5756eaf55aba2f45;p=vcrpy.git Nicer error for can't overwrite existing cassette Raise CannotOverwriteExistingCassetteException rather than Exception. Include cassette filename and record mode in error message. --- diff --git a/vcr/stubs/__init__.py b/vcr/stubs/__init__.py index 801a93c..c02ac54 100644 --- a/vcr/stubs/__init__.py +++ b/vcr/stubs/__init__.py @@ -6,6 +6,10 @@ from cStringIO import StringIO from vcr.request import Request +class CannotOverwriteExistingCassetteException(Exception): + pass + + def parse_headers(header_list): headers = "".join(header_list) + "\r\n" msg = HTTPMessage(StringIO(headers)) @@ -172,9 +176,10 @@ class VCRConnectionMixin: return VCRHTTPResponse(response) else: if self.cassette.write_protected: - raise Exception( - "Can't overwrite existing cassette in \ - your current record mode." + raise CannotOverwriteExistingCassetteException( + "Can't overwrite existing cassette (%r) in " + "your current record mode (%r)." + % (self.cassette._path, self.cassette.record_mode) ) # Otherwise, we should send the request, then get the response