You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Program.cs
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -35,5 +35,18 @@ public static void Main(string[] args) {
35
35
});
36
36
});
37
37
app.Run();
38
+
39
+
// Add a middleware to catch exceptions and stop the host gracefully
40
+
app.Use(async(context,next)=>{
41
+
try{
42
+
awaitnext.Invoke();
43
+
}catch(Exceptionex){
44
+
Console.Error.WriteLine($"Triggering shutdown due to exception caught in global exception handler. Error: {ex.Message}. Stack Trace: {ex.StackTrace}");
45
+
46
+
// Stop the host gracefully so it triggers the pod to error
0 commit comments