domain-errors 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. domain_errors/__init__.py +27 -0
  2. domain_errors/common/__init__.py +1 -0
  3. domain_errors/common/constants/__init__.py +1 -0
  4. domain_errors/common/constants/tests.py +1 -0
  5. domain_errors/config/__init__.py +1 -0
  6. domain_errors/config/_version.py +3 -0
  7. domain_errors/decorators/__init__.py +1 -0
  8. domain_errors/decorators/wrap_errors/__init__.py +8 -0
  9. domain_errors/decorators/wrap_errors/wrap_errors_client.py +95 -0
  10. domain_errors/domains/__init__.py +1 -0
  11. domain_errors/domains/cloud/__init__.py +5 -0
  12. domain_errors/domains/cloud/cloud_client.py +18 -0
  13. domain_errors/domains/constants/__init__.py +1 -0
  14. domain_errors/domains/constants/cloud.py +20 -0
  15. domain_errors/domains/constants/domain_error.py +20 -0
  16. domain_errors/domains/constants/http.py +20 -0
  17. domain_errors/domains/constants/python.py +20 -0
  18. domain_errors/domains/domain_error/__init__.py +1 -0
  19. domain_errors/domains/domain_error/domain_error.py +22 -0
  20. domain_errors/domains/http/__init__.py +5 -0
  21. domain_errors/domains/http/http_client.py +18 -0
  22. domain_errors/domains/python/__init__.py +5 -0
  23. domain_errors/domains/python/python_client.py +26 -0
  24. domain_errors/py.typed +0 -0
  25. domain_errors/services/__init__.py +1 -0
  26. domain_errors/services/chain/__init__.py +11 -0
  27. domain_errors/services/chain/chain_client.py +90 -0
  28. domain_errors/services/chain/chain_objects.py +89 -0
  29. domain_errors/services/constants/__init__.py +1 -0
  30. domain_errors/services/constants/chain.py +14 -0
  31. domain_errors/services/constants/services.py +1 -0
  32. domain_errors-0.1.0.dist-info/METADATA +298 -0
  33. domain_errors-0.1.0.dist-info/RECORD +35 -0
  34. domain_errors-0.1.0.dist-info/WHEEL +4 -0
  35. domain_errors-0.1.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,27 @@
1
+ """Typed domain error hierarchy with wrapping and chaining for Python services."""
2
+
3
+ from domain_errors.config._version import __version__
4
+ from domain_errors.decorators.wrap_errors.wrap_errors_client import (
5
+ WrapErrorsClient,
6
+ wrap_errors,
7
+ )
8
+ from domain_errors.domains.domain_error.domain_error import DomainError
9
+ from domain_errors.services.chain.chain_client import ErrorChain
10
+ from domain_errors.services.chain.chain_objects import (
11
+ ChainLink,
12
+ ChainVia,
13
+ DomainClassifier,
14
+ DomainCrossing,
15
+ )
16
+
17
+ __all__ = [
18
+ "ChainLink",
19
+ "ChainVia",
20
+ "DomainClassifier",
21
+ "DomainCrossing",
22
+ "DomainError",
23
+ "ErrorChain",
24
+ "WrapErrorsClient",
25
+ "__version__",
26
+ "wrap_errors",
27
+ ]
@@ -0,0 +1 @@
1
+ """Cross-cutting utilities and shared helpers."""
@@ -0,0 +1 @@
1
+ """Common constants."""
@@ -0,0 +1 @@
1
+ """Shared test constants."""
@@ -0,0 +1 @@
1
+ """Package configuration."""
@@ -0,0 +1,3 @@
1
+ """Single-source package version."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1 @@
1
+ """Decorators: error-wrapping for fallible boundaries."""
@@ -0,0 +1,8 @@
1
+ """@wrap_errors decorator adapter."""
2
+
3
+ from domain_errors.decorators.wrap_errors.wrap_errors_client import (
4
+ WrapErrorsClient,
5
+ wrap_errors,
6
+ )
7
+
8
+ __all__ = ["WrapErrorsClient", "wrap_errors"]
@@ -0,0 +1,95 @@
1
+ """@wrap_errors: wrap a fallible callable's errors into a DomainError via ErrorChain."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import functools
6
+ import inspect
7
+ from collections.abc import Awaitable, Callable
8
+ from dataclasses import dataclass
9
+ from typing import Any, ParamSpec, TypeVar, cast
10
+
11
+ from domain_errors.domains.domain_error.domain_error import DomainError
12
+ from domain_errors.services.chain.chain_client import ErrorChain
13
+
14
+ Params = ParamSpec("Params")
15
+ Return = TypeVar("Return")
16
+
17
+
18
+ @dataclass(frozen=True, slots=True)
19
+ class WrapErrorsClient:
20
+ """Wrap a fallible callable's errors into a target DomainError via ErrorChain; DomainError passes through."""
21
+
22
+ as_: type[DomainError]
23
+ catch: tuple[type[Exception], ...]
24
+ message: str | None
25
+ capture: bool
26
+
27
+ @classmethod
28
+ def for_target(
29
+ cls,
30
+ as_: type[DomainError],
31
+ *,
32
+ catch: tuple[type[Exception], ...] = (Exception,),
33
+ message: str | None = None,
34
+ capture: bool = True,
35
+ ) -> WrapErrorsClient:
36
+ """Build a wrap_errors decorator targeting the given DomainError type."""
37
+ return cls(as_=as_, catch=catch, message=message, capture=capture)
38
+
39
+ def __call__(self, func: Callable[Params, Return]) -> Callable[Params, Return]:
40
+ """Wrap func so caught errors become a DomainError via ErrorChain; DomainError passes through. Sync + async."""
41
+ if inspect.iscoroutinefunction(func):
42
+ async_func = cast("Callable[Params, Awaitable[Any]]", func)
43
+
44
+ @functools.wraps(func)
45
+ async def async_wrapper(*args: Params.args, **kwargs: Params.kwargs) -> Any:
46
+ try:
47
+ return await async_func(*args, **kwargs)
48
+ except DomainError:
49
+ raise
50
+ except self.catch as error:
51
+ raise self._as_domain(error, func, args, kwargs) from error
52
+
53
+ return cast("Callable[Params, Return]", async_wrapper)
54
+
55
+ @functools.wraps(func)
56
+ def wrapper(*args: Params.args, **kwargs: Params.kwargs) -> Return:
57
+ try:
58
+ return func(*args, **kwargs)
59
+ except DomainError:
60
+ raise
61
+ except self.catch as error:
62
+ raise self._as_domain(error, func, args, kwargs) from error
63
+
64
+ return wrapper
65
+
66
+ def _as_domain(
67
+ self,
68
+ error: Exception,
69
+ func: Callable[..., Any],
70
+ args: tuple[Any, ...],
71
+ kwargs: dict[str, Any],
72
+ ) -> DomainError:
73
+ """Wrap a caught error into the target DomainError with the captured call context."""
74
+ return ErrorChain.wrap(
75
+ error,
76
+ as_=self.as_,
77
+ message=self.message,
78
+ **self._capture(func, args, kwargs),
79
+ )
80
+
81
+ def _capture(
82
+ self,
83
+ func: Callable[..., Any],
84
+ args: tuple[Any, ...],
85
+ kwargs: dict[str, Any],
86
+ ) -> dict[str, Any]:
87
+ """Bind the call's args to parameter names for error context; empty when capture is off."""
88
+ if not self.capture:
89
+ return {}
90
+ bound = inspect.signature(func).bind(*args, **kwargs)
91
+ bound.apply_defaults()
92
+ return dict(bound.arguments)
93
+
94
+
95
+ wrap_errors = WrapErrorsClient.for_target
@@ -0,0 +1 @@
1
+ """Domain taxonomy: the DomainError base class and foreign error-family adapters."""
@@ -0,0 +1,5 @@
1
+ """AWS cloud error-family domain adapter."""
2
+
3
+ from domain_errors.domains.cloud.cloud_client import CloudClassifier, cloud
4
+
5
+ __all__ = ["CloudClassifier", "cloud"]
@@ -0,0 +1,18 @@
1
+ """AWS cloud-SDK exception-family domain classifier."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from domain_errors.domains.constants import cloud as const
6
+
7
+
8
+ class CloudClassifier:
9
+ """Classify botocore and boto3 exceptions into the cloud domain."""
10
+
11
+ def classify(self, err: BaseException) -> str | None:
12
+ """Return const.CLOUD when err originates in an AWS-SDK library, else None."""
13
+ if type(err).__module__.split(".")[0] in const.CLOUD_LIBRARIES:
14
+ return const.CLOUD
15
+ return None
16
+
17
+
18
+ cloud = CloudClassifier()
@@ -0,0 +1 @@
1
+ """Domain adapter constants."""
@@ -0,0 +1,20 @@
1
+ """Cloud classifier domain name and recognized libraries. Imported as const."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Final
6
+
7
+ __all__ = [
8
+ "CLOUD",
9
+ "CLOUD_LIBRARIES",
10
+ ]
11
+
12
+
13
+ """Cloud-layer domain the classifier maps AWS-SDK (botocore/boto3) errors to."""
14
+
15
+ CLOUD: Final = "cloud"
16
+
17
+
18
+ """Top-level package names of the AWS-SDK libraries classified by origin."""
19
+
20
+ CLOUD_LIBRARIES: Final = frozenset({"botocore", "boto3"})
@@ -0,0 +1,20 @@
1
+ """Domain error defaults. Imported as const."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Final
6
+
7
+ __all__ = [
8
+ "DEFAULT_CODE",
9
+ "DEFAULT_DOMAIN",
10
+ "DEFAULT_HTTP_STATUS",
11
+ "DEFAULT_MESSAGE",
12
+ ]
13
+
14
+
15
+ """Base-class contract defaults; consumer subclasses override these per error type."""
16
+
17
+ DEFAULT_CODE: Final = "domain_error"
18
+ DEFAULT_DOMAIN: Final = "application"
19
+ DEFAULT_HTTP_STATUS: Final = 500
20
+ DEFAULT_MESSAGE: Final = "An unspecified domain error occurred."
@@ -0,0 +1,20 @@
1
+ """HTTP classifier domain name and recognized libraries. Imported as const."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Final
6
+
7
+ __all__ = [
8
+ "HTTP",
9
+ "HTTP_LIBRARIES",
10
+ ]
11
+
12
+
13
+ """HTTP-layer domain the classifier maps httpx/requests/aiohttp errors to."""
14
+
15
+ HTTP: Final = "http"
16
+
17
+
18
+ """Top-level package names of the HTTP-client libraries classified by origin."""
19
+
20
+ HTTP_LIBRARIES: Final = frozenset({"httpx", "requests", "aiohttp"})
@@ -0,0 +1,20 @@
1
+ """Stdlib classifier domain names. Imported as const."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Final
6
+
7
+ __all__ = [
8
+ "ASSERTION",
9
+ "LOGIC",
10
+ "NETWORK",
11
+ "OS",
12
+ ]
13
+
14
+
15
+ """Coarse domains the stdlib classifier maps exception families to."""
16
+
17
+ ASSERTION: Final = "assertion"
18
+ LOGIC: Final = "logic"
19
+ NETWORK: Final = "network"
20
+ OS: Final = "os"
@@ -0,0 +1 @@
1
+ """Domain error base class."""
@@ -0,0 +1,22 @@
1
+ """DomainError: base class for per-project typed exception hierarchies."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from domain_errors.domains.constants import domain_error as const
6
+
7
+
8
+ class DomainError(Exception):
9
+ """Base for per-project typed exception hierarchies."""
10
+
11
+ code: str = const.DEFAULT_CODE
12
+ domain: str = const.DEFAULT_DOMAIN
13
+
14
+ http_status: int = const.DEFAULT_HTTP_STATUS
15
+ default_message: str = const.DEFAULT_MESSAGE
16
+ retryable: bool = False
17
+
18
+ def __init__(self, message: str | None = None, **context: object) -> None:
19
+ """Store the message and logger context, then initialize Exception."""
20
+ self.message = message or self.default_message
21
+ self.context = context
22
+ super().__init__(self.message)
@@ -0,0 +1,5 @@
1
+ """HTTP error-family domain adapter."""
2
+
3
+ from domain_errors.domains.http.http_client import HttpClassifier, http
4
+
5
+ __all__ = ["HttpClassifier", "http"]
@@ -0,0 +1,18 @@
1
+ """HTTP exception-family domain classifier."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from domain_errors.domains.constants import http as const
6
+
7
+
8
+ class HttpClassifier:
9
+ """Classify httpx, requests, and aiohttp exceptions into the http domain."""
10
+
11
+ def classify(self, err: BaseException) -> str | None:
12
+ """Return const.HTTP when err originates in an HTTP-client library, else None."""
13
+ if type(err).__module__.split(".")[0] in const.HTTP_LIBRARIES:
14
+ return const.HTTP
15
+ return None
16
+
17
+
18
+ http = HttpClassifier()
@@ -0,0 +1,5 @@
1
+ """Stdlib exception-family domain adapter."""
2
+
3
+ from domain_errors.domains.python.python_client import PythonClassifier, python
4
+
5
+ __all__ = ["PythonClassifier", "python"]
@@ -0,0 +1,26 @@
1
+ """Stdlib exception-family domain classifier."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from domain_errors.domains.constants import python as const
6
+
7
+
8
+ class PythonClassifier:
9
+ """Classify stdlib exceptions into coarse domains."""
10
+
11
+ _FAMILIES: tuple[tuple[tuple[type[BaseException], ...], str], ...] = (
12
+ ((ConnectionError, TimeoutError), const.NETWORK),
13
+ ((FileNotFoundError, PermissionError, OSError), const.OS),
14
+ ((ValueError, KeyError, TypeError), const.LOGIC),
15
+ ((AssertionError,), const.ASSERTION),
16
+ )
17
+
18
+ def classify(self, err: BaseException) -> str | None:
19
+ """Return err's stdlib domain, or None when no family matches."""
20
+ for types, domain in self._FAMILIES:
21
+ if isinstance(err, types):
22
+ return domain
23
+ return None
24
+
25
+
26
+ python = PythonClassifier()
domain_errors/py.typed ADDED
File without changes
@@ -0,0 +1 @@
1
+ """Error chaining services."""
@@ -0,0 +1,11 @@
1
+ """Error chaining: typed wrap, full cascade history, and cross-domain crossings (ErrorChain + ChainLink/DomainCrossing value objects)."""
2
+
3
+ from domain_errors.services.chain.chain_client import ErrorChain
4
+ from domain_errors.services.chain.chain_objects import (
5
+ ChainLink,
6
+ ChainVia,
7
+ DomainClassifier,
8
+ DomainCrossing,
9
+ )
10
+
11
+ __all__ = ["ChainLink", "ChainVia", "DomainClassifier", "DomainCrossing", "ErrorChain"]
@@ -0,0 +1,90 @@
1
+ """Error chaining operations: wrap, history, crossings."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TypeVar
6
+
7
+ from domain_errors.domains.domain_error.domain_error import DomainError
8
+ from domain_errors.services.chain.chain_objects import (
9
+ ChainLink,
10
+ ChainVia,
11
+ DomainClassifier,
12
+ DomainCrossing,
13
+ )
14
+ from domain_errors.services.constants import chain as const
15
+
16
+ TypeDomainError = TypeVar("TypeDomainError", bound=DomainError)
17
+
18
+
19
+ class ErrorChain:
20
+ """Stateless chaining operations for typed domain errors."""
21
+
22
+ @staticmethod
23
+ def wrap(
24
+ err: Exception,
25
+ *,
26
+ as_: type[TypeDomainError],
27
+ message: str | None = None,
28
+ **context: object,
29
+ ) -> TypeDomainError:
30
+ """Construct a typed domain error for the caller to raise with from err."""
31
+ return as_(message=message, **context)
32
+
33
+ @staticmethod
34
+ def history(
35
+ err: BaseException,
36
+ classifiers: tuple[DomainClassifier, ...] = (),
37
+ ) -> tuple[ChainLink, ...]:
38
+ """Walk the full exception cascade into links, the error itself first."""
39
+ links: list[ChainLink] = []
40
+ seen: set[int] = set()
41
+ current: BaseException | None = err
42
+ via = ChainVia.ROOT
43
+ while current is not None and id(current) not in seen:
44
+ seen.add(id(current))
45
+ links.append(
46
+ ChainLink(
47
+ type_name=current.__class__.__name__,
48
+ message=str(current),
49
+ code=getattr(current, "code", None),
50
+ domain=ErrorChain._domain_of(current, classifiers),
51
+ via=via,
52
+ context=getattr(current, "context", {}),
53
+ )
54
+ )
55
+ if current.__cause__ is not None:
56
+ current = current.__cause__
57
+ via = ChainVia.CAUSE
58
+ elif not current.__suppress_context__:
59
+ current = current.__context__
60
+ via = ChainVia.CONTEXT
61
+ else:
62
+ current = None
63
+ return tuple(links)
64
+
65
+ @staticmethod
66
+ def crossings(
67
+ err: BaseException,
68
+ classifiers: tuple[DomainClassifier, ...] = (),
69
+ ) -> tuple[DomainCrossing, ...]:
70
+ """Return the causation hops where the cascade crossed domains."""
71
+ links = ErrorChain.history(err, classifiers)
72
+ found: list[DomainCrossing] = []
73
+ for effect, cause in zip(links, links[1:]):
74
+ if cause.domain != effect.domain:
75
+ found.append(DomainCrossing(cause=cause, effect=effect))
76
+ return tuple(found)
77
+
78
+ @staticmethod
79
+ def _domain_of(
80
+ err: BaseException, classifiers: tuple[DomainClassifier, ...]
81
+ ) -> str:
82
+ """Resolve an error's domain from its contract or the first matching classifier."""
83
+ domain = getattr(err, "domain", None)
84
+ if isinstance(domain, str):
85
+ return domain
86
+ for classifier in classifiers:
87
+ verdict = classifier.classify(err)
88
+ if verdict is not None:
89
+ return verdict
90
+ return const.DEFAULT_DOMAIN
@@ -0,0 +1,89 @@
1
+ """Error chaining value objects: links, crossings, via tags, and the classifier contract."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import asdict, dataclass, field
6
+ from enum import StrEnum
7
+ from typing import Protocol
8
+
9
+
10
+ class ChainVia(StrEnum):
11
+ """How a link entered the chain."""
12
+
13
+ ROOT = "root"
14
+ CAUSE = "cause"
15
+ CONTEXT = "context"
16
+
17
+
18
+ class DomainClassifier(Protocol):
19
+ """Contract a domain adapter satisfies to classify foreign errors."""
20
+
21
+ def classify(self, err: BaseException) -> str | None:
22
+ """Return the error's domain, or None when it is not this family."""
23
+ ...
24
+
25
+
26
+ @dataclass(frozen=True, slots=True)
27
+ class LinkLogExtra:
28
+ """Structured-logging payload for one chain link."""
29
+
30
+ type: str
31
+ message: str
32
+ code: str | None
33
+ domain: str
34
+ via: str
35
+ context: dict[str, object]
36
+
37
+
38
+ @dataclass(frozen=True, slots=True)
39
+ class CrossingLogExtra:
40
+ """Structured-logging payload for one cross-domain crossing."""
41
+
42
+ cause_type: str
43
+ cause_domain: str
44
+ effect_type: str
45
+ effect_domain: str
46
+
47
+
48
+ @dataclass(frozen=True, slots=True)
49
+ class ChainLink:
50
+ """One hop of an exception chain, ready for structured logging."""
51
+
52
+ type_name: str
53
+ message: str
54
+ code: str | None
55
+ domain: str
56
+ via: ChainVia
57
+ context: dict[str, object] = field(default_factory=dict, compare=False)
58
+
59
+ def to_log_extra(self) -> dict[str, object]:
60
+ """Return the link as a JSON-ready dict for logger extra."""
61
+ return asdict(
62
+ LinkLogExtra(
63
+ type=self.type_name,
64
+ message=self.message,
65
+ code=self.code,
66
+ domain=self.domain,
67
+ via=self.via.value,
68
+ context=self.context,
69
+ )
70
+ )
71
+
72
+
73
+ @dataclass(frozen=True, slots=True)
74
+ class DomainCrossing:
75
+ """One causation hop where the error crossed from one domain to another."""
76
+
77
+ cause: ChainLink
78
+ effect: ChainLink
79
+
80
+ def to_log_extra(self) -> dict[str, object]:
81
+ """Return the crossing as a JSON-ready dict for logger extra."""
82
+ return asdict(
83
+ CrossingLogExtra(
84
+ cause_type=self.cause.type_name,
85
+ cause_domain=self.cause.domain,
86
+ effect_type=self.effect.type_name,
87
+ effect_domain=self.effect.domain,
88
+ )
89
+ )
@@ -0,0 +1 @@
1
+ """Error concern constants."""
@@ -0,0 +1,14 @@
1
+ """Error-chaining constants. Imported as const."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Final
6
+
7
+ __all__ = [
8
+ "DEFAULT_DOMAIN",
9
+ ]
10
+
11
+
12
+ """Domain assigned to an error when no classvar or classifier resolves it."""
13
+
14
+ DEFAULT_DOMAIN: Final = "python"
@@ -0,0 +1 @@
1
+ """Error constants (Stage 1 placeholder)."""
@@ -0,0 +1,298 @@
1
+ Metadata-Version: 2.4
2
+ Name: domain-errors
3
+ Version: 0.1.0
4
+ Summary: Typed domain error hierarchy with wrapping and chaining for Python services
5
+ Project-URL: Homepage, https://pypi.org/project/domain-errors/
6
+ Project-URL: Repository, https://github.com/jekhator/domain-errors
7
+ Project-URL: Issues, https://github.com/jekhator/domain-errors/issues
8
+ Project-URL: Changelog, https://github.com/jekhator/domain-errors/blob/main/CHANGELOG.md
9
+ Author: James Ekhator
10
+ License: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: chaining,error-handling,errors,exceptions,typed
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+
23
+ # domain-errors
24
+
25
+ [![PyPI](https://img.shields.io/pypi/v/domain-errors)](https://pypi.org/project/domain-errors/)
26
+ [![CI](https://github.com/jekhator/domain-errors/actions/workflows/ci.yml/badge.svg)](https://github.com/jekhator/domain-errors/actions)
27
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)
28
+ [![Python](https://img.shields.io/badge/python-3.11%2B-blue)](https://www.python.org/downloads/)
29
+
30
+ Typed domain error hierarchy with wrapping and chaining for Python services.
31
+
32
+ Define per-domain exception types with a structured contract (code, domain, HTTP status, retryability). Wrap foreign exceptions into domain errors, walk causation chains, and detect when errors cross domain boundaries—all ready for structured logging.
33
+
34
+ ## Why?
35
+
36
+ Service errors should carry semantic meaning: *what* failed (code), *where* it failed (domain), *how* to handle it (HTTP status, retryability), and *why* it happened (context). Cross-service calls risk mixing domains—database errors become API errors become payment errors. `domain-errors` makes this hierarchy explicit and traceable.
37
+
38
+ ```python
39
+ from domain_errors import DomainError, ErrorChain
40
+
41
+ class DatabaseError(DomainError):
42
+ domain = "database"
43
+ code = "db_error"
44
+ http_status = 503
45
+ retryable = True
46
+
47
+ try:
48
+ user = db.query("SELECT * FROM users WHERE id = $1", user_id)
49
+ except Exception as e:
50
+ raise ErrorChain.wrap(
51
+ e,
52
+ as_=DatabaseError,
53
+ message=f"Failed to fetch user {user_id}",
54
+ user_id=user_id
55
+ ) from e
56
+ ```
57
+
58
+ ## Installation
59
+
60
+ ```bash
61
+ pip install domain-errors
62
+ ```
63
+
64
+ or with uv:
65
+
66
+ ```bash
67
+ uv add domain-errors
68
+ ```
69
+
70
+ Requires Python 3.11+.
71
+
72
+ ## Quick Start
73
+
74
+ ### 1. Define a domain error
75
+
76
+ Subclass `DomainError` with a code, domain, HTTP status, and message:
77
+
78
+ ```python
79
+ from domain_errors import DomainError
80
+
81
+ class PaymentError(DomainError):
82
+ code = "payment_declined"
83
+ domain = "payment"
84
+ http_status = 402
85
+ retryable = False
86
+ default_message = "Payment was declined."
87
+ ```
88
+
89
+ ### 2. Raise with structured context
90
+
91
+ Include context keyword arguments for metrics and audit trails:
92
+
93
+ ```python
94
+ raise PaymentError(
95
+ message="Card declined: insufficient funds",
96
+ transaction_id="txn_xyz789",
97
+ amount_cents=5000,
98
+ currency="USD"
99
+ )
100
+ ```
101
+
102
+ ### 3. Wrap foreign exceptions
103
+
104
+ Convert caught exceptions into domain errors, preserving the chain:
105
+
106
+ ```python
107
+ try:
108
+ result = stripe.Charge.create(amount=5000, source=card_token)
109
+ except stripe.error.CardError as e:
110
+ raise ErrorChain.wrap(
111
+ e,
112
+ as_=PaymentError,
113
+ message=f"Card charge failed: {e.user_message}",
114
+ transaction_id=e.http_body["id"]
115
+ ) from e
116
+ ```
117
+
118
+ ### 4. Trace and log the chain
119
+
120
+ Walk the exception chain to find domain crossings and log structured data:
121
+
122
+ ```python
123
+ try:
124
+ process_payment(amount_cents=5000)
125
+ except DomainError as err:
126
+ # Get the full chain
127
+ links = ErrorChain.history(err)
128
+ for link in links:
129
+ logger.error("Error in chain", extra=link.to_log_extra())
130
+
131
+ # Find where errors crossed domains
132
+ crossings = ErrorChain.crossings(err)
133
+ for crossing in crossings:
134
+ logger.warning("Domain boundary crossed", extra=crossing.to_log_extra())
135
+
136
+ # Return API response
137
+ return {
138
+ "status": err.http_status,
139
+ "code": err.code,
140
+ "message": err.message
141
+ }
142
+ ```
143
+
144
+ ## Public API
145
+
146
+ ### DomainError
147
+
148
+ Base class for domain-specific exceptions. Define subclasses with a contract:
149
+
150
+ ```python
151
+ class MyError(DomainError):
152
+ code: str = "my_error" # Unique error code
153
+ domain: str = "my_domain" # Namespace (auth, database, etc.)
154
+ http_status: int = 400 # HTTP status for API responses
155
+ retryable: bool = False # Transient failure?
156
+ default_message: str = "..." # Fallback message
157
+ ```
158
+
159
+ **Constructor:**
160
+ ```python
161
+ error = MyError(
162
+ message="Custom message", # optional; defaults to default_message
163
+ **context # structured data: user_id=123, txn_id="x"
164
+ )
165
+ ```
166
+
167
+ **Attributes:**
168
+ - `message: str` — the error message
169
+ - `context: dict[str, object]` — structured context data
170
+
171
+ ### ErrorChain
172
+
173
+ Static methods for wrapping, walking, and analyzing exception chains.
174
+
175
+ **Methods:**
176
+ - `ErrorChain.wrap(err, as_=ErrorType, message=None, **context)` — Construct a typed domain error for the caller to raise `from err`.
177
+ - `ErrorChain.history(err, classifiers=())` — Walk the exception chain; return a tuple of `ChainLink` objects.
178
+ - `ErrorChain.crossings(err, classifiers=())` — Find causation hops where errors crossed domains; return a tuple of `DomainCrossing` objects.
179
+
180
+ ### ChainLink
181
+
182
+ One hop in an exception chain, ready for structured logging.
183
+
184
+ ```python
185
+ link = ChainLink(
186
+ type_name="TimeoutError",
187
+ message="[Errno 110] Connection timed out",
188
+ code=None,
189
+ domain="python",
190
+ via=ChainVia.CONTEXT,
191
+ context={}
192
+ )
193
+
194
+ # Convert to JSON-ready dict for logger extra:
195
+ logger.error("Exception", extra=link.to_log_extra())
196
+ ```
197
+
198
+ ### DomainCrossing
199
+
200
+ A causation hop where errors changed domains.
201
+
202
+ ```python
203
+ crossing = DomainCrossing(
204
+ cause=ChainLink(...), # e.g., TimeoutError (python)
205
+ effect=ChainLink(...) # e.g., APIError (api)
206
+ )
207
+
208
+ logger.warning("Domain boundary", extra=crossing.to_log_extra())
209
+ ```
210
+
211
+ ### DomainClassifier (Protocol)
212
+
213
+ Optional contract for resolving domains of foreign exceptions:
214
+
215
+ ```python
216
+ class MyClassifier:
217
+ def classify(self, err: BaseException) -> str | None:
218
+ """Return domain name, or None if not applicable."""
219
+ if isinstance(err, TimeoutError):
220
+ return "stdlib"
221
+ return None
222
+
223
+ links = ErrorChain.history(err, classifiers=(MyClassifier(),))
224
+ ```
225
+
226
+ Built-in classifiers are provided for standard library, HTTP-client, and AWS SDK exceptions:
227
+
228
+ ```python
229
+ from domain_errors.domains.python import python
230
+ from domain_errors.domains.http import http
231
+ from domain_errors.domains.cloud import cloud
232
+
233
+ # Classify stdlib exceptions
234
+ links = ErrorChain.history(err, classifiers=(python,))
235
+
236
+ # Classify httpx, requests, and aiohttp exceptions
237
+ links = ErrorChain.history(err, classifiers=(http,))
238
+
239
+ # Classify botocore and boto3 exceptions
240
+ links = ErrorChain.history(err, classifiers=(cloud,))
241
+
242
+ # Compose multiple classifiers
243
+ links = ErrorChain.history(err, classifiers=(python, http, cloud))
244
+ ```
245
+
246
+ ### @wrap_errors
247
+
248
+ Decorator for automatic error wrapping. Catches specified exceptions, wraps them into a target DomainError, and captures function arguments for structured logging:
249
+
250
+ ```python
251
+ from domain_errors import DomainError, wrap_errors
252
+
253
+ class StorageError(DomainError):
254
+ code = "storage_error"
255
+ domain = "storage"
256
+ http_status = 503
257
+
258
+ @wrap_errors(StorageError, catch=(FileNotFoundError, IOError))
259
+ def read_config(path: str) -> str:
260
+ with open(path) as f:
261
+ return f.read()
262
+
263
+ # Manual wrapping (before)
264
+ try:
265
+ config = read_config("/etc/app.yaml")
266
+ except FileNotFoundError as e:
267
+ raise ErrorChain.wrap(e, as_=StorageError, path=path) from e
268
+
269
+ # Declarative wrapping (after)
270
+ @wrap_errors(StorageError, catch=(FileNotFoundError, IOError))
271
+ def read_config(path: str) -> str:
272
+ with open(path) as f:
273
+ return f.read()
274
+
275
+ try:
276
+ config = read_config("/etc/app.yaml")
277
+ except StorageError as err:
278
+ # err.context includes {'path': '/etc/app.yaml'}
279
+ # err.__cause__ is the original FileNotFoundError
280
+ pass
281
+ ```
282
+
283
+ DomainError instances pass through unchanged; works on sync and async callables; set `capture=False` to omit arguments (e.g., for secrets).
284
+
285
+ ## Documentation
286
+
287
+ - **DomainError Base:** [docs/apps/domain_error.md](docs/apps/domain_error.md) — class contract, subclassing, message/context semantics
288
+ - **ErrorChain:** [docs/apps/chain.md](docs/apps/chain.md) — wrap, history, crossings, logging integration
289
+ - **@wrap_errors Decorator:** [docs/apps/wrap_errors.md](docs/apps/wrap_errors.md) — declarative error wrapping for functions and async callables
290
+ - **Architecture:** [docs/apps/diagrams.md](docs/apps/diagrams.md) — data flow and domain relationships
291
+
292
+ ## License
293
+
294
+ Apache 2.0 — see LICENSE file.
295
+
296
+ ## Contributing
297
+
298
+ Contributions welcome via pull requests. This library is maintained by [James Ekhator](https://github.com/jekhator).
@@ -0,0 +1,35 @@
1
+ domain_errors/__init__.py,sha256=jY_lhH-Lc_Q9KQlVz-jRsJkGwDQ0H-zrLUg_sAXxBzM,709
2
+ domain_errors/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ domain_errors/common/__init__.py,sha256=oMWsbD45wSXSZ7L3eQJ_3Cj4gtV38rNSeHd41ua9ud0,50
4
+ domain_errors/common/constants/__init__.py,sha256=I6bOENFqOiquTKv-3JEq9xMUE1FR2QA1B2F905jutfk,24
5
+ domain_errors/common/constants/tests.py,sha256=ol-TOs8vv8z0eIr3oqxEEBeQDst6KPT8YcAH3nan5M8,29
6
+ domain_errors/config/__init__.py,sha256=GIjb9cYcaJ1Q9vRzF7_daH_S5KLOeg_oLGfPIhmn7A0,29
7
+ domain_errors/config/_version.py,sha256=GtsljaQReBaQusaK0Zmip2AM7BWtdesXvaMQz35Aiic,60
8
+ domain_errors/decorators/__init__.py,sha256=5TWoFs7yVCAxykOI2SYi27r6YiPDya9alAG3H421b9s,58
9
+ domain_errors/decorators/wrap_errors/__init__.py,sha256=Wua2I7E4qBzncV3zErObgv9L2St6o_ENlQR8eotAIF8,197
10
+ domain_errors/decorators/wrap_errors/wrap_errors_client.py,sha256=_Tl46HqCE0t5LaIf5U5DSG7p0zyQEdaZbEUZ5-DrMEc,3244
11
+ domain_errors/domains/__init__.py,sha256=PvA-qL2hWGLRRLyukkICEM70QlUaGC30yi-jRjKWvMQ,85
12
+ domain_errors/domains/cloud/__init__.py,sha256=W8cyOJPviEahRfqjXnElV1ZO5BdwTPnVzuK2v8JVUgw,162
13
+ domain_errors/domains/cloud/cloud_client.py,sha256=j7AS_D77mTA5hmkoJ1Rt30jgpQWljKzspV9r8l0ynvI,546
14
+ domain_errors/domains/constants/__init__.py,sha256=J19T4XMeky7avD8auE9bvPBX85Teagi05EN8xvnrQyI,32
15
+ domain_errors/domains/constants/cloud.py,sha256=dNXSvDy-Nng7bb0u_mmUbOvrwCo6P3PH2SW-qgpXtw0,438
16
+ domain_errors/domains/constants/domain_error.py,sha256=mcS6XZxhLFG7AoWqkfLeL6yFv-GChPCZobDXyPY26VU,480
17
+ domain_errors/domains/constants/http.py,sha256=8pmS--I8OXrrTX-LzKoIhfH6JPxgsr4FVbDo9FcziSk,444
18
+ domain_errors/domains/constants/python.py,sha256=8HRuTPph8rDDT-yH3aFhLrHr5A1La5wMewZ3GdlMGOQ,361
19
+ domain_errors/domains/domain_error/__init__.py,sha256=-opiMlhaigLUQFDleEfqAr2yLEtPM1iy_qCEtGChFvk,31
20
+ domain_errors/domains/domain_error/domain_error.py,sha256=bEWoaUHxX2j9X-u0rOSPsJdjkJWnOqBIC-pBm2xFrXE,756
21
+ domain_errors/domains/http/__init__.py,sha256=dfisAhPHFxncgGoXyESoGMpTqC7fbJQ_o7m8qv7lijM,151
22
+ domain_errors/domains/http/http_client.py,sha256=WCc8v_SUWpX7nUwCsSVTVhpi6l_bP7C1jaHlMdiiu1Y,543
23
+ domain_errors/domains/python/__init__.py,sha256=oAPYHt0mGDX54KI2hnn63ct7cHLQ6KfmVhPkGbpNpoQ,169
24
+ domain_errors/domains/python/python_client.py,sha256=IzSZ_Q9W1DLPaMCBrkdlvhD6i5IN9hoHMlReSUTJUhE,838
25
+ domain_errors/services/__init__.py,sha256=MNp46ZnKeUGO2F0Tokv4JduME1MHBmdSAfRIu4LvQGM,31
26
+ domain_errors/services/chain/__init__.py,sha256=xC_uGahdKAiTEtJ6rXnoQMskfK6JWbx5Zllj-LOUbbw,423
27
+ domain_errors/services/chain/chain_client.py,sha256=rSHjmM0ZEFIgP2VjskOlCHJas3kgN5MZSBLxBW5hwHs,3113
28
+ domain_errors/services/chain/chain_objects.py,sha256=SU0bSOQkHpT6s4nSUNZP5LElKMldbvskgbYCX-ycvVc,2350
29
+ domain_errors/services/constants/__init__.py,sha256=XhBV7AXjDeSxvvW5C_MkuaeX2l_9UPwRZhkqC8Lj5jk,31
30
+ domain_errors/services/constants/chain.py,sha256=vVKtrT6zq5WvNb9rDZ2VPUtYl_VOIaxe4Tmcvm61KmE,264
31
+ domain_errors/services/constants/services.py,sha256=qZY3s97jBehZ0eN1fs73k1ujYweGkGndrxxEfjoxU60,45
32
+ domain_errors-0.1.0.dist-info/METADATA,sha256=wEbPE9VU0ipuMzV720CVhErJeIgoykZk8R2l3i2dEiw,9159
33
+ domain_errors-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
34
+ domain_errors-0.1.0.dist-info/licenses/LICENSE,sha256=afJnNvtqk-WIQDM8aNaqfuYQifp27Wa0Q5j5P_Aj_gQ,11343
35
+ domain_errors-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 James Ekhator
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.