Capture unexpected API errors to Sentry

Non-APIError HassioError exceptions reaching api_process indicate
missing error handling in the endpoint handler. In addition to the
logging added in the previous commit, also send these to Sentry so
they surface as actionable issues rather than silently returning
"Unknown error, see Supervisor logs" to the caller.
This commit is contained in:
Stefan Agner
2026-04-16 17:19:13 +02:00
parent c0a1b71f5c
commit 84ca80617c

View File

@@ -32,6 +32,7 @@ from ..jobs import JobSchedulerOptions, SupervisorJob
from ..utils import check_exception_chain, get_message_from_exception_chain
from ..utils.json import json_dumps, json_loads as json_loads_util
from ..utils.log_format import format_message
from ..utils.sentry import async_capture_exception
from . import const
_LOGGER: logging.Logger = logging.getLogger(__name__)
@@ -76,6 +77,7 @@ def api_process(method):
)
except HassioError as err:
_LOGGER.exception("Unexpected error during API call: %s", err)
await async_capture_exception(err)
return api_return_error(err)
if isinstance(answer, (dict, list)):
@@ -124,6 +126,7 @@ def api_process_raw(content, *, error_type=None):
)
except HassioError as err:
_LOGGER.exception("Unexpected error during API call: %s", err)
await async_capture_exception(err)
return api_return_error(
err, error_type=error_type or const.CONTENT_TYPE_BINARY
)