mirror of
https://github.com/home-assistant/supervisor.git
synced 2026-04-25 18:02:43 +00:00
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:
@@ -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
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user