| |
@@ -10,15 +10,14 @@
|
| |
import cherrypy
|
| |
|
| |
|
| |
- class ProviderException(Exception, Log):
|
| |
+ class ProviderException(cherrypy.HTTPError, Log):
|
| |
code = 500
|
| |
message = None
|
| |
|
| |
def __init__(self, message, code=None):
|
| |
- super(ProviderException, self).__init__(message)
|
| |
+ super(ProviderException, self).__init__(code or self.code,
|
| |
+ self.message)
|
| |
self.message = message
|
| |
- if code:
|
| |
- self.code = code
|
| |
self.debug('%s [%s]' % (self.message, self.code))
|
| |
|
| |
def __str__(self):
|
| |
This makes a ProviderException(400, ..) actually send a 400 status code,
and display the correct message.
Otherwise, we were sending an error 500, because cherrypy did not
know how to interpret Exception's rather than cherrypy.HTTPError.
Signed-off-by: Patrick Uiterwijk puiterwijk@redhat.com