2424from models_library .projects import ProjectID
2525from servicelib .aiohttp import status
2626from servicelib .aiohttp .typing_extension import Handler
27+ from servicelib .logging_errors import create_troubleshotting_log_kwargs
2728
2829from .._constants import INDEX_RESOURCE_NAME
2930from ..director_v2 ._core_computations import create_or_update_pipeline
@@ -258,17 +259,21 @@ async def wrapper(request: web.Request) -> web.StreamResponse:
258259
259260 except Exception as err :
260261 error_code = create_error_code (err )
262+ front_end_msg = compose_support_error_msg (
263+ msg = MSG_UNEXPECTED_ERROR .format (hint = "" ), error_code = error_code
264+ )
261265 _logger .exception (
262- "Unexpected failure while dispatching study [%s]" ,
263- f"{ error_code } " ,
264- extra = {"error_code" : error_code },
266+ ** create_troubleshotting_log_kwargs (
267+ front_end_msg ,
268+ exception = err ,
269+ tip = "Unexpected failure while dispatching study" ,
270+ )
265271 )
272+
266273 raise create_redirect_to_page_response (
267274 request .app ,
268275 page = "error" ,
269- message = compose_support_error_msg (
270- msg = MSG_UNEXPECTED_ERROR .format (hint = "" ), error_code = error_code
271- ),
276+ message = front_end_msg ,
272277 status_code = status .HTTP_500_INTERNAL_SERVER_ERROR ,
273278 ) from err
274279
@@ -327,13 +332,18 @@ async def get_redirection_to_study_page(request: web.Request) -> web.Response:
327332 # we cannot accept any more users.
328333 #
329334 error_code = create_error_code (exc )
335+
336+ front_end_msg = MSG_TOO_MANY_GUESTS
330337 _logger .exception (
331- "Failed to create guest user. Responded with 429 Too Many Requests [%s]" ,
332- f"{ error_code } " ,
333- extra = {"error_code" : error_code },
338+ ** create_troubleshotting_log_kwargs (
339+ front_end_msg ,
340+ exception = exc ,
341+ tip = "Failed to create guest user. Responded with 429 Too Many Requests" ,
342+ )
334343 )
344+
335345 raise RedirectToFrontEndPageError (
336- MSG_TOO_MANY_GUESTS ,
346+ front_end_msg ,
337347 error_code = error_code ,
338348 status_code = status .HTTP_429_TOO_MANY_REQUESTS ,
339349 ) from exc
@@ -353,15 +363,25 @@ async def get_redirection_to_study_page(request: web.Request) -> web.Response:
353363
354364 except Exception as exc : # pylint: disable=broad-except
355365 error_code = create_error_code (exc )
366+
367+ front_end_msg = MSG_UNEXPECTED_ERROR .format (hint = "while copying your study" )
356368 _logger .exception (
357- "Failed while copying project '%s' to '%s' [%s]" ,
358- template_project .get ("name" ),
359- user .get ("email" ),
360- f"{ error_code } " ,
361- extra = {"error_code" : error_code },
369+ ** create_troubleshotting_log_kwargs (
370+ front_end_msg ,
371+ exception = exc ,
372+ error_context = {
373+ "user_id" : user .get ("id" ),
374+ "user" : dict (user ),
375+ "template_project" : {
376+ k : template_project .get (k ) for k in ["name" , "uuid" ]
377+ },
378+ },
379+ tip = f"Failed while copying project '{ template_project .get ('name' )} ' to '{ user .get ('email' )} '" ,
380+ )
362381 )
382+
363383 raise RedirectToFrontEndPageError (
364- MSG_UNEXPECTED_ERROR . format ( hint = "while copying your study" ) ,
384+ front_end_msg ,
365385 error_code = error_code ,
366386 status_code = status .HTTP_500_INTERNAL_SERVER_ERROR ,
367387 ) from exc
0 commit comments