"""Standard REST exception that gets converted to the Response it passes in"""
def__init__(self,response):
self.response=response
classNotFoundException(RESTException):
"""Standard 404 exception when REST resource is not found"""
def__init__(self,resourceName,invalidValue):
RESTException.__init__(self,Response(404,"Unable to find %s identified by '%s'"%(resourceName,invalidValue),{"x-corepost-resource":resourceName,"x-corepost-value":invalidValue}))
classConflictException(RESTException):
"""Standard 409 exception when REST resource is not found. Allows to pass in a custom message with more details"""
RESTException.__init__(self,Response(409,"Conflict for %s identified by '%s': %s"%(resourceName,invalidValue,message),{"x-corepost-resource":resourceName,"x-corepost-value":invalidValue}))
classAlreadyExistsException(ConflictException):
"""Standard 409 exception when REST resource already exists during a POST"""