* src/docgen/PdfDoc.py: provide a more useful error when reportlab crashes

svn: r8070
This commit is contained in:
Brian Matherly 2007-02-07 04:37:32 +00:00
parent 1fb8b84264
commit 76e09f5f6e
2 changed files with 16 additions and 0 deletions

View File

@ -1,3 +1,6 @@
2007-02-06 Brian Matherly <brian@gramps-project.org>
* src/docgen/PdfDoc.py: provide a more useful error when reportlab crashes
2007-02-06 Douglas Blank <dblank@cs.brynmawr.edu>
* src/ReportBase/_ReportDialog.py: 0000905: Typo in catching exceptions in
buggy reports

View File

@ -69,6 +69,7 @@ try:
import reportlab.graphics.shapes
import reportlab.lib.styles
from reportlab.pdfbase.pdfmetrics import *
from reportlab.platypus.doctemplate import LayoutError
for faceName in reportlab.pdfbase.pdfmetrics.standardFonts:
reportlab.pdfbase.pdfmetrics.registerTypeFace(
@ -185,6 +186,18 @@ class PdfDoc(BaseDoc.BaseDoc):
except IOError,msg:
errmsg = "%s\n%s" % (_("Could not create %s") % self.filename, msg)
raise Errors.ReportError(errmsg)
except LayoutError,msg:
if str(msg).rfind("too large on page") > -1:
errmsg = "Reportlab is unable to layout your report. " + \
"This is probably because you have some text that " + \
"is too large to fit on one page or in one cell. " + \
"Try changing some report options or use a " + \
"different output format."
else:
errmsg = "Reportlab is unable to layout your report. " + \
"Try changing some report options or use a " + \
"different output format."
raise Errors.ReportError(errmsg)
if self.print_req:
apptype = 'application/pdf'