File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
services/resource-usage-tracker/src/simcore_service_resource_usage_tracker/exceptions Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 22
33
44class ResourceUsageTrackerBaseError (OsparcErrorMixin , Exception ):
5- msg_template = "Resource Usage Tracker unknown error "
5+ msg_template = "Resource usage Tracker Service Error "
66
77
88class ConfigurationError (ResourceUsageTrackerBaseError ):
9- msg_template = "Resource usage Tracker configuration error"
9+ ...
1010
1111
1212### NotCreatedDBError
Original file line number Diff line number Diff line change 1+ import logging
12from collections .abc import Callable
23from typing import Awaitable
34
45from fastapi import HTTPException , Request , status
56from fastapi .encoders import jsonable_encoder
7+ from servicelib .logging_errors import create_troubleshotting_log_kwargs
8+ from servicelib .status_codes_utils import is_5xx_server_error
69from starlette .responses import JSONResponse
710
811from ...exceptions .errors import RutNotFoundError
912
13+ _logger = logging .getLogger (__name__ )
1014
11- async def http_error_handler (_ : Request , exc : Exception ) -> JSONResponse :
15+
16+ async def http_error_handler (request : Request , exc : Exception ) -> JSONResponse :
1217 assert isinstance (exc , HTTPException ) # nosec
18+
19+ if is_5xx_server_error (exc .status_code ):
20+ _logger .exception (
21+ ** create_troubleshotting_log_kwargs (
22+ "Unexpected error happened in the Resource Usage Tracker. Please contact support." ,
23+ error = exc ,
24+ error_context = {
25+ "request" : request ,
26+ "request.method" : f"{ request .method } " ,
27+ },
28+ )
29+ )
1330 return JSONResponse (
1431 content = jsonable_encoder ({"errors" : [exc .detail ]}), status_code = exc .status_code
1532 )
You can’t perform that action at this time.
0 commit comments