File tree Expand file tree Collapse file tree 1 file changed +9
-14
lines changed
src/Web/Grand.Web.Common/Infrastructure Expand file tree Collapse file tree 1 file changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -59,22 +59,17 @@ public static void UseGrandExceptionHandler(this WebApplication application)
5959 return ;
6060 }
6161
62- try
62+ if ( DataSettingsManager . DatabaseIsInstalled ( ) )
6363 {
64- //check whether database is installed
65- if ( DataSettingsManager . DatabaseIsInstalled ( ) )
66- {
67- var logger = context . RequestServices . GetRequiredService < ILoggerFactory > ( )
68- . CreateLogger ( "UseExceptionHandler" ) ;
69- //log error
70- logger . LogError ( exception , exception . Message ) ;
71- }
72- }
73- finally
74- {
75- //rethrow the exception to show the error page
76- throw exception ;
64+ var logger = context . RequestServices . GetRequiredService < ILoggerFactory > ( )
65+ . CreateLogger ( "UseExceptionHandler" ) ;
66+ // Log the error
67+ logger . LogError ( exception , exception . Message ) ;
7768 }
69+
70+ // Set the response status code and message without throwing
71+ context . Response . StatusCode = StatusCodes . Status500InternalServerError ;
72+ await context . Response . WriteAsync ( "An unexpected error occurred." ) ;
7873 } ) ;
7974 } ) ;
8075 }
You can’t perform that action at this time.
0 commit comments