Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mgr / volumes: improve error handling
This cleans up lots of return-fu statements and make the source look much more pythonic. Functions should raise an instance of VolumeException() class wherever necessary (error handling). Fixes: http://tracker.ceph.com/issues/39969 Signed-off-by: Venky Shankar <vshankar@redhat.com> (cherry picked from commit 241c9ce)
- Loading branch information
Showing
4 changed files
with
234 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class VolumeException(Exception): | ||
def __init__(self, error_code, error_message): | ||
self.errno = error_code | ||
self.error_str = error_message | ||
|
||
def to_tuple(self): | ||
return self.errno, "", self.error_str | ||
|
||
def __str__(self): | ||
return "{0} ({1})".format(self.errno, self.error_str) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.