0001###########################################################################
0002# PyGeo - a dynamic geometry toolkit
0003# Copyright (C) 2005 Arthur Siegel (ajsiegel@optonline.com)
0004#
0005# This library is free software; you can redistribute it and/or
0006# modify it under the terms of the GNU Lesser General Public
0007# License as published by the Free Software Foundation; either
0008# version 2.1 of the License, or (at your option) any later version.
0009#
0010# This library is distributed in the hope that it will be useful,
0011# but WITHOUT ANY WARRANTY; without even the implied warranty of
0012# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013# Lesser General Public License for more details.
0014#
0015# You should have received a copy of the GNU Lesser General Public
0016# License along with this library; if not, write to the Free Software
0017# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
0018#
0019#PyGeo homepage: http://pygeo.sourceforge.net
0020###########################################################################
0021
0022"""customization of Errors to be raised in PyGeo code"""
0023
0024class Error(Exception):
0025    """Base class for exceptions in this module."""
0026    pass
0027
0028
0029class Assignment_Error(Error):
0030    """Exception raised for errors in the input.
0031
0032    Attributes:
0033        expression -- input expression in which the error occurred
0034        message -- explanation of the error
0035    """
0036
0037    def __init__(self,e, value):
0038        self.value=value
0039        self.e = e
0040    def __str__(self):
0041        str = "attempted value is %s of type %s" %(self.value,type(self.value))
0042        return str
0043
0044
0045class Argument_Len_Error(Error):
0046    """Exception raised for errors in the input.
0047    
0048    Attributes:
0049        expression -- input expression in which the error occurred
0050        message -- explanation of the error
0051    """
0052
0053    def __init__(self, e,args):
0054        self.e=e
0055        self.args = args
0056
0057    def __str__(self):
0058        str = "tgest"
0059        return str
0060
0061class Argument_Type_Error(Error):
0062    """Exception raised for errors in the input.
0063
0064    Attributes:
0065        expression -- input expression in which the error occurred
0066        message -- explanation of the error
0067    """
0068
0069    def __init__(self,sigs,args):
0070        self.sigs = sigs
0071        self.args = args
0072        self.goodargs=[]
0073        for a in self.sigs:
0074            argset=[]
0075            for b in a:
0076                argset.append(b.__name__)
0077            self.goodargs.append(argset)
0078
0079    def __str__(self):
0080        str=" class requires arguments derived from one of: %s  arguments given: %s "           %( self.goodargs,
0082         [x.__class__.__base__.__name__ for x in self.args])
0083        return str
0084
0085# module attributes (for pudge auto documentation)
0086__author__ = "Arthur Siegel <ajsiegel@optonline.com>"
0087__date__ = "Date: 2006-02-02"
0088__revision__ = "Revision: a1"
0089__url__ = "http://source.net/projects/pygeo"
0090__license__ ="GPL <http://www.opensource.org/licenses/gpl-license.php>"