ssscoring.errors

 1# See: https://github.com/pr3d4t0r/SSScoring/blob/master/LICENSE.txt
 2
 3
 4import json
 5
 6
 7# +++ classes +++
 8
 9class SSScoringError(Exception):
10    """
11    Abstract class that defines all exceptions and errors and has a dictionary
12    representation of itself, for cleaner structured logging.
13
14    Arguments
15    ---------
16        message : str
17    A meaningful error message, human-readable
18        errno : int
19    An optional integer value, similar to ERRNO in C/UNIX
20    """
21    def __init__(self, message: str, errno: int = -1):
22        self._info = message
23        self._errno = errno
24
25
26    def __str__(self):
27        e = {  'SSScoringError': self._info, 'errno': self._errno, }
28
29        return json.dumps(e)
class SSScoringError(builtins.Exception):
10class SSScoringError(Exception):
11    """
12    Abstract class that defines all exceptions and errors and has a dictionary
13    representation of itself, for cleaner structured logging.
14
15    Arguments
16    ---------
17        message : str
18    A meaningful error message, human-readable
19        errno : int
20    An optional integer value, similar to ERRNO in C/UNIX
21    """
22    def __init__(self, message: str, errno: int = -1):
23        self._info = message
24        self._errno = errno
25
26
27    def __str__(self):
28        e = {  'SSScoringError': self._info, 'errno': self._errno, }
29
30        return json.dumps(e)

Abstract class that defines all exceptions and errors and has a dictionary representation of itself, for cleaner structured logging.

Arguments

message : str

A meaningful error message, human-readable errno : int An optional integer value, similar to ERRNO in C/UNIX

SSScoringError(message: str, errno: int = -1)
22    def __init__(self, message: str, errno: int = -1):
23        self._info = message
24        self._errno = errno