From 41fa1065c69f55def87e3fcecad602076d7cd790 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 25 Oct 2009 09:38:58 -0400 Subject: Treat missing source files nicer. --- coverage/cmdline.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 0915b10..1029ad6 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -3,6 +3,7 @@ import optparse, sys from coverage.execfile import run_python_file +from coverage.misc import CoverageException class Opts(object): @@ -283,6 +284,8 @@ CMDS = { } +OK, ERR = 0, 1 + class CoverageScript(object): """The command-line interface to Coverage.""" @@ -330,7 +333,6 @@ class CoverageScript(object): """ # Collect the command-line options. - OK, ERR = 0, 1 if not argv: self.help_fn(topic='minimum_help') @@ -566,4 +568,10 @@ def main(): This is installed as the script entrypoint. """ - return CoverageScript().command_line(sys.argv[1:]) + try: + status = CoverageScript().command_line(sys.argv[1:]) + except CoverageException: + _, err, _ = sys.exc_info() + print(err) + status = ERR + return status -- cgit v1.2.1