Some classes derived from SavannaException do not overload the "message" and "code" members correctly
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Sahara |
Triaged
|
Medium
|
Unassigned |
Bug Description
There are some classes derived from SavannaException that do not override message and code members correctly, so that when they are raised the exception message is incorrect. This can result for instance in validation error messages through the REST api that say "An unknown exception occurred" instead of the correct error.
The code should be searched for all derivations from SavannaException, and the declarations and __init_ methods checked.
The SavannException class is declared like this:
class SavannaExceptio
"""Base Exception for the project
To correctly use this class, inherit from it and define
a 'message' and 'code' properties.
"""
message = "An unknown exception occurred"
code = "UNKNOWN_EXCEPTION"
def __str__(self):
return self.message
Derived classes need to set message and code either by overriding the values outside of the __init__ method or by referencing them as self.message and self.code. This is a correct example:
class InvalidExceptio
message = "Invalid object reference"
def __init__(self, message=None):
self.code = "INVALID_REFERENCE"
if message:
Here is an incorrect example. The message and code members inside the __init__ are local to the method, they should be referenced as self.message and self.code or the assignments should be moved outside of __init__:
class HiveWithoutJobT
def __init__(self):
message = "Hive cannot be configured without JobTracker"
code = "HIVE_WITHOUT_
Changed in savanna: | |
status: | New → Triaged |
importance: | Undecided → Medium |
milestone: | none → 0.3a1 |