blob: 2b1389b9a8262d125a721466ada54a8b6fb9ec58 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
"""Errors caused by calls to external services."""
import traceback
from uuid import uuid4
class ExternalRequestError(Exception):
"""Raise when a request to an external endpoint fails."""
def __init__(self,
externaluri: str,
error: Exception,
extrainfo: str = ""):
"""Initialise the error message."""
self.errorid = uuid4()
self.error = error
self.extrainfo = extrainfo
super().__init__(
f"error-id: {self.errorid}: We got an error of type "
f"'{type(error).__name__}' trying to access {externaluri}:\n\n "
f"{''.join(traceback.format_exception(error))} " +
(f"\n\n{extrainfo}" if bool(extrainfo) else ""))
|