def ui_error_handler(request: Request, exception: Exception, error_type: str, error_message: str, templates: Jinja2Templates, template_path: Path, context: Optional[Dict] = None, status_code: int = 500) -> Response: """Return a UI view of the error.""" logger.info('Interactive environment so returning error template') logger.debug(f'Path: {template_path}') logger.debug(f'Exception: {exception}') if context is None: context = {} error_context = context.copy() error = exception detail = '' if exception.args: logger.info('Getting args') error = exception.args[0] if len(exception.args) > 1: detail = exception.args[1] error_context.update({'error': str(error), 'status_code': str(status_code), 'error_type': error_type, 'error_description': error_message, 'error_detail': str(detail), 'request': request}) # type: ignore logger.debug(f'Error context: {error_context}') return templates.TemplateResponse(template_path.name, error_context, status_code=status_code)
async def root(): return Jinja2Templates.TemplateResponse()