diff --git a/src/calibre/ebooks/__init__.py b/src/calibre/ebooks/__init__.py index 0fceb4bcf8..73bd375812 100644 --- a/src/calibre/ebooks/__init__.py +++ b/src/calibre/ebooks/__init__.py @@ -7,7 +7,10 @@ from various formats. ''' class ConversionError(Exception): - pass + + def __init__(self, msg, only_msg=False): + Exception.__init__(self, msg) + self.only_msg = only_msg class UnknownFormatError(Exception): pass diff --git a/src/calibre/ebooks/lrf/pdf/convert_from.py b/src/calibre/ebooks/lrf/pdf/convert_from.py index 9c201da224..2adb9a12a7 100644 --- a/src/calibre/ebooks/lrf/pdf/convert_from.py +++ b/src/calibre/ebooks/lrf/pdf/convert_from.py @@ -38,7 +38,7 @@ def generate_html(pathtopdf, logger): p = popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE) except OSError, err: if err.errno == 2: - raise ConversionError(_('Could not find pdftohtml, check it is in your PATH')) + raise ConversionError(_('Could not find pdftohtml, check it is in your PATH'), True) else: raise logger.info(p.stdout.read()) @@ -47,10 +47,10 @@ def generate_html(pathtopdf, logger): err = p.stderr.read() raise ConversionError, err if not os.path.exists(index) or os.stat(index).st_size < 100: - raise ConversionError(os.path.basename(pathtopdf) + _(' does not allow copying of text.')) + raise ConversionError(os.path.basename(pathtopdf) + _(' does not allow copying of text.'), True) raw = open(index).read(4000) if not '>sys.stderr, formatted_traceback.encode('utf8', 'ignore') if isinstance(formatted_traceback, unicode) else formatted_traceback except: pass + if getattr(exception, 'only_msg', False): + error_dialog(self, _('Conversion Error'), unicode(exception)).exec_() + return msg = u'

%s: %s

'%exception msg += u'

Failed to perform job: '+description msg += u'

Detailed traceback:

'