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

View File

@ -774,7 +774,7 @@ class GenericFilterList:
except: except:
return 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') f.write('<filters>\n')
for i in self.filter_list: for i in self.filter_list:
f.write(' <filter name="%s"' % self.fix(i.get_name())) f.write(' <filter name="%s"' % self.fix(i.get_name()))

View File

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

View File

@ -97,7 +97,14 @@ class StyleListDisplay:
"""Called with the OK button is clicked; Calls the callback task, then """Called with the OK button is clicked; Calls the callback task, then
saves the stylesheet, and destroys the window.""" saves the stylesheet, and destroys the window."""
self.callback() 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) Utils.destroy_passed_object(obj)
def on_button_press(self,obj,event): 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. Loads the StyleSheets from the associated file, if it exists.
""" """
try: try:
parser = make_parser() p = make_parser()
parser.setContentHandler(SheetParser(self)) p.setContentHandler(SheetParser(self))
if self.file[0:7] != "file://": p.parse('file://' + self.file)
self.file = "file://" + self.file
parser.parse(self.file)
except (IOError,OSError,SAXParseException): except (IOError,OSError,SAXParseException):
pass pass

View File

@ -233,7 +233,16 @@ class KwordDoc(TextDoc.TextDoc):
self.f.write('</PIXMAPS>\n') self.f.write('</PIXMAPS>\n')
self.f.write('</DOC>\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("documentinfo.xml",self.mtime,self.m)
tar.add_file("maindoc.xml",self.mtime,self.f) tar.add_file("maindoc.xml",self.mtime,self.f)
for file in self.photo_list: for file in self.photo_list:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,3 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
@ -24,7 +23,10 @@
import RelLib import RelLib
import os import os
import sort import sort
import Errors
from intl import gettext as _ from intl import gettext as _
from QuestionDialog import ErrorDialog
from Report import * from Report import *
from TextDoc import * from TextDoc import *
@ -733,10 +735,15 @@ class DetAncestorReportDialog(TextReportDialog):
"""Create the object that will produce the Detailed Ancestral """Create the object that will produce the Detailed Ancestral
Report. All user dialog has already been handled and the Report. All user dialog has already been handled and the
output file opened.""" output file opened."""
MyReport = DetAncestorReport(self.db, self.person, self.target_path, try:
self.max_gen, self.pg_brk, self.doc) MyReport = DetAncestorReport(self.db, self.person, self.target_path,
MyReport.write_report() 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 import sort
from intl import gettext as _ from intl import gettext as _
import Errors
from Report import * from Report import *
from TextDoc import * from TextDoc import *
import gtk import gtk
import gnome.ui import gnome.ui
from QuestionDialog import ErrorDialog
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
@ -761,10 +763,15 @@ class DetDescendantReportDialog(TextReportDialog):
"""Create the object that will produce the Detailed Ancestral """Create the object that will produce the Detailed Ancestral
Report. All user dialog has already been handled and the Report. All user dialog has already been handled and the
output file opened.""" output file opened."""
MyReport = DetDescendantReport(self.db, self.person, self.target_path, try:
self.max_gen, self.pg_brk, self.doc) MyReport = DetDescendantReport(self.db, self.person, self.target_path,
MyReport.write_report() 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): def add_user_options(self):

View File

@ -35,7 +35,9 @@ import os
import RelLib import RelLib
import Report import Report
import TextDoc import TextDoc
import Errors
from intl import gettext as _ 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. """Create the object that will produce the Ancestor Chart.
All user dialog has already been handled and the output file All user dialog has already been handled and the output file
opened.""" opened."""
MyReport = FamilyGroup(self.db, self.report_menu, self.target_path, self.doc) try:
MyReport.setup() MyReport = FamilyGroup(self.db, self.report_menu, self.target_path, self.doc)
MyReport.write_report() 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 StyleEditor
import Report import Report
import GenericFilter import GenericFilter
import Errors
from QuestionDialog import ErrorDialog
from intl import gettext as _ from intl import gettext as _
#------------------------------------------------------------------------ #------------------------------------------------------------------------
@ -532,10 +534,17 @@ class IndivSummaryDialog(Report.TextReportDialog):
opened.""" opened."""
act = self.use_srcs.get_active() act = self.use_srcs.get_active()
MyReport = IndivComplete(self.db, self.person, self.target_path, try:
self.doc, self.filter, act) MyReport = IndivComplete(self.db, self.person, self.target_path,
MyReport.setup() self.doc, self.filter, act)
MyReport.write_report() MyReport.setup()
MyReport.write_report()
except Errors.ReportError, msg:
ErrorDialog(str(msg))
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
def get_report_generations(self): def get_report_generations(self):
"""Return the default number of generations to start the """Return the default number of generations to start the

View File

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