Report error exceptions

svn: r1275
This commit is contained in:
Don Allingham 2003-01-29 04:43:12 +00:00
parent 16fa3b0b8f
commit 71ee24226d
16 changed files with 103 additions and 56 deletions

View File

@ -21,6 +21,7 @@
class ReportError(Exception):
"""Error used to report Report errors"""
def __init__(self,value):
Exception.__init__(self)
self.value = value
def __str__(self):
@ -29,6 +30,7 @@ class ReportError(Exception):
class GedcomError(Exception):
"""Error used to report GEDCOM errors"""
def __init__(self,value):
Exception.__init__(self)
self.value = value
def __str__(self):
@ -37,6 +39,7 @@ class GedcomError(Exception):
class PluginError(Exception):
"""Error used to report plugin errors"""
def __init__(self,value):
Exception.__init__(self)
self.value = value
def __str__(self):

View File

@ -774,7 +774,7 @@ class GenericFilterList:
except:
return
f.write("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n")
f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
f.write('<filters>\n')
for i in self.filter_list:
f.write(' <filter name="%s"' % self.fix(i.get_name()))

View File

@ -52,8 +52,9 @@ import TextDoc
import StyleEditor
import GrampsCfg
import PaperMenu
from intl import gettext as _
import Errors
from intl import gettext as _
from QuestionDialog import ErrorDialog
#-------------------------------------------------------------------------
@ -78,20 +79,6 @@ _template_map = {
_user_template : None
}
#-------------------------------------------------------------------------
#
# Exceptions
#
#-------------------------------------------------------------------------
class ReportError(Exception):
def __init__(self,value):
self.value = value
def __str__(self):
return self.value
#-------------------------------------------------------------------------
#
# Report

View File

@ -97,7 +97,14 @@ class StyleListDisplay:
"""Called with the OK button is clicked; Calls the callback task, then
saves the stylesheet, and destroys the window."""
self.callback()
self.sheetlist.save()
try:
self.sheetlist.save()
except IOError,msg:
from QuestionDialog import ErrorDialog
ErrorDialog(_("Error saving stylesheet") + "\n" + str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
Utils.destroy_passed_object(obj)
def on_button_press(self,obj,event):

View File

@ -790,11 +790,9 @@ class StyleSheetList:
Loads the StyleSheets from the associated file, if it exists.
"""
try:
parser = make_parser()
parser.setContentHandler(SheetParser(self))
if self.file[0:7] != "file://":
self.file = "file://" + self.file
parser.parse(self.file)
p = make_parser()
p.setContentHandler(SheetParser(self))
p.parse('file://' + self.file)
except (IOError,OSError,SAXParseException):
pass

View File

@ -233,7 +233,16 @@ class KwordDoc(TextDoc.TextDoc):
self.f.write('</PIXMAPS>\n')
self.f.write('</DOC>\n')
tar = TarFile(self.filename)
try:
tar = TarFile(self.filename)
except IOError, msg:
text = _("Could not open %s") % self.filename
Errors.ReportError(text + "\n" + str(msg))
return
except:
Errors.ReportError(_("Could not open %s") % self.filename)
return
tar.add_file("documentinfo.xml",self.mtime,self.m)
tar.add_file("maindoc.xml",self.mtime,self.f)
for file in self.photo_list:

View File

@ -71,6 +71,8 @@ class OpenOfficeDoc(TextDoc.TextDoc):
self.filename = filename + ".sxw"
else:
self.filename = filename
self.filename = os.path.normpath(os.path.abspath(filename))
try:
self.content_xml = tempfile.mktemp()

View File

@ -46,6 +46,7 @@ import TextDoc
import Report
import Errors
import FontScale
from QuestionDialog import ErrorDialog
from SubstKeywords import SubstKeywords
from intl import gettext as _
@ -255,6 +256,8 @@ class AncestorChartDialog(Report.DrawReportDialog):
MyReport = AncestorChart(self.db, self.person, self.target_path,
self.max_gen, self.doc, self.report_text)
MyReport.write_report()
except Errors.ReportError, msg:
ErrorDialog(str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()

View File

@ -28,14 +28,6 @@
import os
import string
#------------------------------------------------------------------------
#
# GNOME/GTK
#
#------------------------------------------------------------------------
import gtk
import gnome.ui
#------------------------------------------------------------------------
#
# gramps modules
@ -44,6 +36,8 @@ import gnome.ui
import Report
import TextDoc
import RelLib
import Errors
from QuestionDialog import ErrorDialog
from intl import gettext as _
#------------------------------------------------------------------------
@ -60,11 +54,7 @@ class AncestorReport(Report.Report):
self.max_generations = max
self.pgbrk = pgbrk
self.doc = doc
try:
self.doc.open(output)
except IOError,msg:
gnome.ui.GnomeErrorDialog(_("Could not open %s") % output + "\n" + msg)
self.doc.open(output)
def filter(self,person,index):
if person == None or index >= (1 << 30):
@ -277,11 +267,12 @@ class AncestorReportDialog(Report.TextReportDialog):
MyReport = AncestorReport(self.db, self.person, self.target_path,
self.max_gen, self.doc, self.pg_brk)
MyReport.write_report()
except Errors.ReportError, msg:
ErrorDialog(str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#------------------------------------------------------------------------
#
#

View File

@ -48,6 +48,7 @@ import Errors
from SubstKeywords import SubstKeywords
from intl import gettext as _
from QuestionDialog import ErrorDialog
#------------------------------------------------------------------------
#
@ -341,6 +342,8 @@ class DescendantReportDialog(Report.DrawReportDialog):
MyReport = DescendantReport(self.db,self.report_text,
self.person, self.target_path, self.doc)
MyReport.write_report()
except Errors.ReportError, msg:
ErrorDialog(str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()

View File

@ -36,6 +36,9 @@ import string
#------------------------------------------------------------------------
import Report
import TextDoc
import Errors
from QuestionDialog import ErrorDialog
from intl import gettext as _
#------------------------------------------------------------------------
@ -161,6 +164,8 @@ class DescendantReportDialog(Report.TextReportDialog):
MyReport.setup()
MyReport.report()
MyReport.end()
except Errors.ReportError, msg:
ErrorDialog(str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()

View File

@ -1,4 +1,3 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
@ -24,7 +23,10 @@
import RelLib
import os
import sort
import Errors
from intl import gettext as _
from QuestionDialog import ErrorDialog
from Report import *
from TextDoc import *
@ -733,10 +735,15 @@ class DetAncestorReportDialog(TextReportDialog):
"""Create the object that will produce the Detailed Ancestral
Report. All user dialog has already been handled and the
output file opened."""
MyReport = DetAncestorReport(self.db, self.person, self.target_path,
self.max_gen, self.pg_brk, self.doc)
MyReport.write_report()
try:
MyReport = DetAncestorReport(self.db, self.person, self.target_path,
self.max_gen, self.pg_brk, self.doc)
MyReport.write_report()
except Errors.ReportError, msg:
ErrorDialog(str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#------------------------------------------------------------------------
#

View File

@ -26,11 +26,13 @@ import os
import sort
from intl import gettext as _
import Errors
from Report import *
from TextDoc import *
import gtk
import gnome.ui
from QuestionDialog import ErrorDialog
#------------------------------------------------------------------------
#
@ -761,10 +763,15 @@ class DetDescendantReportDialog(TextReportDialog):
"""Create the object that will produce the Detailed Ancestral
Report. All user dialog has already been handled and the
output file opened."""
MyReport = DetDescendantReport(self.db, self.person, self.target_path,
self.max_gen, self.pg_brk, self.doc)
MyReport.write_report()
try:
MyReport = DetDescendantReport(self.db, self.person, self.target_path,
self.max_gen, self.pg_brk, self.doc)
MyReport.write_report()
except Errors.ReportError, msg:
ErrorDialog(str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
def add_user_options(self):

View File

@ -35,7 +35,9 @@ import os
import RelLib
import Report
import TextDoc
import Errors
from intl import gettext as _
from QuestionDialog import ErrorDialog
#------------------------------------------------------------------------
#
@ -438,9 +440,15 @@ class FamilyGroupDialog(Report.TextReportDialog):
"""Create the object that will produce the Ancestor Chart.
All user dialog has already been handled and the output file
opened."""
MyReport = FamilyGroup(self.db, self.report_menu, self.target_path, self.doc)
MyReport.setup()
MyReport.write_report()
try:
MyReport = FamilyGroup(self.db, self.report_menu, self.target_path, self.doc)
MyReport.setup()
MyReport.write_report()
except Errors.ReportError, msg:
ErrorDialog(str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#------------------------------------------------------------------------
#

View File

@ -37,6 +37,8 @@ import TextDoc
import StyleEditor
import Report
import GenericFilter
import Errors
from QuestionDialog import ErrorDialog
from intl import gettext as _
#------------------------------------------------------------------------
@ -532,10 +534,17 @@ class IndivSummaryDialog(Report.TextReportDialog):
opened."""
act = self.use_srcs.get_active()
MyReport = IndivComplete(self.db, self.person, self.target_path,
self.doc, self.filter, act)
MyReport.setup()
MyReport.write_report()
try:
MyReport = IndivComplete(self.db, self.person, self.target_path,
self.doc, self.filter, act)
MyReport.setup()
MyReport.write_report()
except Errors.ReportError, msg:
ErrorDialog(str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
def get_report_generations(self):
"""Return the default number of generations to start the

View File

@ -45,6 +45,8 @@ import const
import TextDoc
import StyleEditor
import Report
import Errors
from QuestionDialog import ErrorDialog
from intl import gettext as _
#------------------------------------------------------------------------
@ -373,9 +375,15 @@ class IndivSummaryDialog(Report.TextReportDialog):
"""Create the object that will produce the Ancestor Chart.
All user dialog has already been handled and the output file
opened."""
MyReport = IndivSummary(self.db, self.person, self.target_path, self.doc)
MyReport.setup()
MyReport.write_report()
try:
MyReport = IndivSummary(self.db, self.person, self.target_path, self.doc)
MyReport.setup()
MyReport.write_report()
except Errors.ReportError, msg:
ErrorDialog(str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#------------------------------------------------------------------------
#