-
Notifications
You must be signed in to change notification settings - Fork 2
/
error.py
32 lines (25 loc) · 997 Bytes
/
error.py
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
# -*- coding: UTF-8 -*-
# Copyright 2014 Red Hat, Inc.
# Part of clufter project
# Licensed under GPLv2+ (a copy included | http://gnu.org/licenses/gpl-2.0.txt)
"""Base exception classes and exit code definitions"""
__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"
# name the exitcodes
ecodes = 'SUCCESS', 'FAILURE'
EC = type('EC', (), dict((n, v) for v, n
in enumerate('EXIT_' + i for i in ecodes)))
class ClufterError(Exception):
def __init__(self, ctx_self, msg, *args):
self.ctx_self = ctx_self
self.msg = msg
self.args = args
def __str__(self):
ret = ''
if self.ctx_self:
ret = getattr(self.ctx_self, '__name__',
self.ctx_self.__class__.__name__)
ret += ': '
return ret + self.msg.format(*self.args)
class ClufterPlainError(ClufterError):
def __init__(self, msg, *args):
super(ClufterPlainError, self).__init__(None, msg, *args)