From ef26bd83db93a7ebeaf64b0620c98116dda86eaa Mon Sep 17 00:00:00 2001 From: calvin Date: Wed, 27 Oct 2004 12:22:46 +0000 Subject: [PATCH] error message if output file could not be opened git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1878 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- linkchecker | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/linkchecker b/linkchecker index 411f9ded..a7b5fc04 100755 --- a/linkchecker +++ b/linkchecker @@ -427,7 +427,8 @@ if options.output: (options.output, "'-o, --output'")) if options.fileoutput: ns = {'fileoutput': 1} - for ftype in options.fileoutput: + for arg in options.fileoutput: + ftype = arg # look for (optional) filename and encoding if '/' in ftype: ftype, suffix = ftype.split('/', 1) @@ -446,11 +447,17 @@ if options.fileoutput: else: ns['filename'] = suffix if linkcheck.Loggers.has_key(ftype): - logger = config.logger_new(ftype, **ns) + # generating loggers with fileoutput can throw + # an exception when opening the file + try: + logger = config.logger_new(ftype, **ns) + except OSError, msg: + printUsage(_("Illegal argument %r for option %s: %s") % \ + (arg, "'-F, --file-output'", str(msg))) config['fileoutput'].append(logger) else: printUsage(_("Illegal argument %r for option %s") % \ - (ftype, "'-F, --file-output'")) + (arg, "'-F, --file-output'")) if options.interactive is not None: config['interactive'] = options.interactive if options.intern: