jacked._exceptions   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A InjectionError.__init__() 0 9 1
1
"""
2
PRIVATE MODULE: do not import (from) it directly.
3
4
This module contains the ``jacked`` error classes.
5
"""
6
import inspect
7
from typing import Union
8
9
10
class JackedError(Exception):
11
    """
12
    Base class for all ``jacked`` errors.
13
    """
14
15
16
class InvalidUsageError(JackedError):
17
    """
18
    Raised when ``jacked`` was used in the wrong manner (e.g. decorating a
19
    class with ``@inject``).
20
    """
21
22
23
class InjectionError(JackedError):
24
    """
25
    Raised when injection failed.
26
    """
27
    def __init__(self, msg: str, subject: Union[inspect.Parameter, type]):
28
        """
29
        Constructor.
30
        :param msg: the message of the error.
31
        :param subject: a parameter in case of a decorator injection, a type in
32
        case of ``inject_here`` was used.
33
        """
34
        super(InjectionError, self).__init__(msg)
35
        self.subject = subject
36