followthemoney.exc

 1from typing import Dict, Optional, TypedDict
 2
 3
 4class ErrorSpec(TypedDict, total=False):
 5    properties: Dict[str, str]
 6
 7
 8class FollowTheMoneyException(Exception):
 9    """Catch-all exception for errors emitted by this library."""
10
11    pass
12
13
14class MetadataException(FollowTheMoneyException):
15    """An exception raised by dataset metadata validation."""
16
17    pass
18
19
20class InvalidData(FollowTheMoneyException):
21    """Schema validation errors will be caught by the API."""
22
23    def __init__(self, message: str, errors: Optional[ErrorSpec] = None) -> None:
24        super(InvalidData, self).__init__(message)
25        self.errors: ErrorSpec = errors or {}
26
27
28class InvalidModel(FollowTheMoneyException):
29    """The schema model is not defined correctly."""
30
31    pass
32
33
34class InvalidMapping(FollowTheMoneyException):
35    """A data mapping was invalid."""
36
37    pass
class ErrorSpec(typing.TypedDict):
5class ErrorSpec(TypedDict, total=False):
6    properties: Dict[str, str]
properties: Dict[str, str]
class FollowTheMoneyException(builtins.Exception):
 9class FollowTheMoneyException(Exception):
10    """Catch-all exception for errors emitted by this library."""
11
12    pass

Catch-all exception for errors emitted by this library.

class MetadataException(FollowTheMoneyException):
15class MetadataException(FollowTheMoneyException):
16    """An exception raised by dataset metadata validation."""
17
18    pass

An exception raised by dataset metadata validation.

class InvalidData(FollowTheMoneyException):
21class InvalidData(FollowTheMoneyException):
22    """Schema validation errors will be caught by the API."""
23
24    def __init__(self, message: str, errors: Optional[ErrorSpec] = None) -> None:
25        super(InvalidData, self).__init__(message)
26        self.errors: ErrorSpec = errors or {}

Schema validation errors will be caught by the API.

InvalidData(message: str, errors: Optional[ErrorSpec] = None)
24    def __init__(self, message: str, errors: Optional[ErrorSpec] = None) -> None:
25        super(InvalidData, self).__init__(message)
26        self.errors: ErrorSpec = errors or {}
errors: ErrorSpec
class InvalidModel(FollowTheMoneyException):
29class InvalidModel(FollowTheMoneyException):
30    """The schema model is not defined correctly."""
31
32    pass

The schema model is not defined correctly.

class InvalidMapping(FollowTheMoneyException):
35class InvalidMapping(FollowTheMoneyException):
36    """A data mapping was invalid."""
37
38    pass

A data mapping was invalid.