1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
# -*- coding: utf-8 -*-
""" Exceptions for isbnlib.dev
The classes in isbnlib.dev should use the exceptions below.
"""
class ISBNLibDevException(Exception):
""" Base class for isbnlib.dev exceptions
This exception should not be raised directly,
only subclasses of this exception should be used!
"""
def __init__(self, msg=None):
if msg:
self.message = '%s (%s)' % (self.message, msg)
def __str__(self):
return getattr(self, 'message', '') # pragma: no cover
class ISBNLibHTTPError(ISBNLibDevException):
""" Exception raised for HTTP related errors
"""
message = "an HTTP error has ocurred"
class ISBNLibURLError(ISBNLibDevException):
""" Exception raised for URL related errors
"""
message = "an URL error has ocurred"
class DataNotFoundAtServiceError(ISBNLibDevException):
""" Exception raised when there is no target data from the service
"""
message = "the target data was not found at this service"
class ServiceIsDownError(ISBNLibDevException):
""" Exception raised when the service is not available
"""
message = "the service is down (try later)"
class DataWrongShapeError(ISBNLibDevException):
""" Exception raised when the data hasn't the expected format
"""
message = "the data hasn't the expected format"
class NoDataForSelectorError(ISBNLibDevException):
""" Exception raised when there is no data for the selector
"""
message = "no data for this selector"
class NotValidMetadataError(ISBNLibDevException):
""" Exception raised when the metadata hasn't the expected format
"""
message = "the metadata hasn't the expected format"
class ISBNNotConsistentError(ISBNLibDevException):
""" Exception raised when the isbn request != isbn response
"""
message = "isbn request != isbn response"
class RecordMappingError(ISBNLibDevException):
""" Exception raised when the mapping records -> canonical doesn't work
"""
message = "the mapping `canonical <- records` doesn't work"
class NoAPIKeyError(ISBNLibDevException):
""" Exception raised when the API Key for a service is not found
"""
message = "this service needs an API key"
class FileNotFoundError(ISBNLibDevException):
""" Exception raised when a given file doesn't exist
"""
message = "the file wasn't found"
|