bbarchivist.exceptions   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 33
rs 10
c 0
b 0
f 0
ccs 11
cts 11
cp 1
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A handle_exception() 0 17 2
1
#!/usr/bin/env python3
2 5
"""This module is used to handle/provide exceptions."""
3
4 5
__author__ = "Thurask"
5 5
__license__ = "WTFPL v2"
6 5
__copyright__ = "2015-2019 Thurask"
7
8
9 5
def handle_exception(exc, msg="SOMETHING WENT WRONG", xit=SystemExit):
10
    """
11
    Print msg, then text of exception exc, then raise exception xit.
12
13
    :param exc: Exception to handle.
14
    :type exc: Exception
15
16
    :param msg: Message to raise, "SOMETHING WENT WRONG" by default.
17
    :type msg: str
18
19
    :param xit: Exception to raise upon exit, SystemExit by default.
20
    :type xit: Exception
21
    """
22 5
    print(msg)
23 5
    print(exc)
24 5
    if xit is not None:
25 5
        raise xit
26
27
28 5
class DummyException(Exception):
29
    """
30
    Exception that is not raised at all.
31
    """
32
    pass
33