Skip to content

Commit

Permalink
♻️ Trying to enhance logging for storage (ITISFoundation#4867)
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHK authored Oct 17, 2023
1 parent d5d6998 commit 07f518f
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from aiohttp import web
from aiohttp.typedefs import Handler
from aiohttp.web_request import Request
Expand All @@ -16,6 +18,8 @@
S3KeyNotFoundError,
)

_logger = logging.getLogger(__name__)


@web.middleware
async def dsm_exception_handler(
Expand All @@ -36,12 +40,15 @@ async def dsm_exception_handler(
except ValidationError as err:
raise web.HTTPUnprocessableEntity(reason=f"{err}") from err
except DBAPIError as err:
_logger.exception("Unexpected error while accessing DB:")
raise web.HTTPServiceUnavailable(
reason=f"Unexpected error while accessing the database: {err}"
) from err
except S3AccessError as err:
_logger.exception("Unexpected error while accessing S3:")
raise web.HTTPServiceUnavailable(
reason=f"Unexpected error while accessing S3 backend: {err}"
) from err
except DatcoreAdapterTimeoutError as err:
_logger.exception("Unexpected error while accessing Datcore-Adapter:")
raise web.HTTPGatewayTimeout(reason=f"{err}") from err

0 comments on commit 07f518f

Please sign in to comment.