"""A module for handling errors and exceptions for the urlrep module """ # Copyright 2005, 2006 EIAO Consoritum # This program is distributed under the terms of the GNU General # Public License. # # This file is part of the European Internet Accessibility Observatory # (EIAO) # # EIAO is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # EIAO is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with EIAO; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA __author__ = "Morten Goodwin Olsen" __version__ = "$Id$" __maintainer__ = "Morten Goodwin Olsen" class URLRepError(Exception): """Basic class for reporting URL repository errors """ class InvalidValueError(URLRepError): """Basic exception handler for invalid values of the URL repository. This works only as a main exception, and should not be raised by itself. """ def __init__(self,msg): URLRepError.__init__(self,msg) class IllegalCountryProperty(InvalidValueError): """The country description is not supported """ def __init__(self,country): """Country not legal""" InvalidValueError.__init__(self,'The Country %s is not within the legal scope.'%(str(country))) class IllegalContinentProperty(InvalidValueError): """The continent description is not supported """ def __init__(self,continent): """Continent not legal""" InvalidValueError.__init__(self,'The continent %s is not within the legal scope.'%(str(continent))) class IllegalScopingRule(InvalidValueError): """The scoping rule is not legal """ def __init__(self,rule): """The Scoping rule is not legal""" InvalidValueError.__init__(self,'The scoping rule provided, %s, is not legal Scoping rules should be written as following: http://www\.example\.com/sommatching.'%(str(rule))) class IllegalNuts3Property(InvalidValueError): """The Nuts3 description is not supported """ def __init__(self,nuts3): """Nuts3 not legal""" InvalidValueError.__init__(self,'The Nuts3 %s is not within the legal scope.'%(str(nuts3))) class IllegalNaceProperty(InvalidValueError): """The nace description is not supported """ def __init__(self,nace): """Nace code not legal""" InvalidValueError.__init__(self,'The nace code %s is not within the legal scope.'%(str(nace))) class IllegalSectorProperty(InvalidValueError): """The sector description is not supported """ def __init__(self,sector): """Sector not legal""" InvalidValueError.__init__(self,'The sector %s is not within the legal scope.'%(str(sector))) class IllegalCategoryProperty(InvalidValueError): """The category description is not supported """ def __init__(self,category): """Category not legal""" InvalidValueError.__init__(self,'The category %s is not within the legal scope.'%(str(category))) class InvalidNError(URLRepError): """Excaption when validator cannot read the url presented """ def __init__(self,n): """Throws an InvalidNError exception. Keyword argumnts: n -- The n which is invalid """ msg = 'Invalid n. The n should be integer larger than 0. (not '+str(n)+')' URLRepError.__init__(self,msg) class PageNotInSiteError(URLRepError): """Excaption when a web page is not present in the site url presented """ def __init__(self,page, site): """Throws an PageNotInSiteError exception. Keyword argumnts: page -- The page not part of the site site -- The site of which the page is not present """ msg = 'Webpage %s is not part of website %s' %(page,site) URLRepError.__init__(self,msg) class InvalidURLError(URLRepError): """Excaption when validator cannot read the url presented """ def __init__(self,URL): """Throws an InvalidNError exception. Keyword argumnts: n -- The n which is invalid """ msg = 'URL not found: '+str(URL) URLRepError.__init__(self,msg)