@@ -63,12 +63,26 @@ class RateLimitExceeded(ogc_api_processes_fastapi.exceptions.OGCAPIException):
63
63
retry_after : int = 0
64
64
65
65
66
- def find_last_context_line (lines : list [str ]) -> int :
67
- index = 0
68
- for i , line in enumerate (lines ):
69
- if "result = context.run(func, *args)" in line :
70
- index = len (lines ) - i - 1
71
- return index
66
+ def get_exc_group_tb (exc_traceback : list [str ]) -> list [str ]:
67
+ """Get and return only the Exception Group Traceback.
68
+
69
+ Parameters
70
+ ----------
71
+ exc_traceback : list[str]
72
+ List of lines in the traceback.
73
+
74
+ Returns
75
+ -------
76
+ list[str]
77
+ List of lines in the traceback.
78
+ """
79
+ exc_group_tb = []
80
+ if "Exception Group Traceback" in exc_traceback [0 ]:
81
+ exc_group_tb .append (exc_traceback [0 ])
82
+ for line in exc_traceback [1 :]:
83
+ if line .lstrip (" " ).startswith (("+" , "|" )):
84
+ exc_group_tb .append (line )
85
+ return exc_group_tb
72
86
73
87
74
88
def format_exception_content (
@@ -210,10 +224,12 @@ def general_exception_handler(
210
224
fastapi.responses.JSONResponse
211
225
"""
212
226
exc_traceback = list (traceback .TracebackException .from_exception (exc ).format ())
213
- last_context_line = find_last_context_line ( list ( exc_traceback ) )
227
+ exc_group_traceback = get_exc_group_tb ( exc_traceback )
214
228
logger .error (
215
229
"internal server error" ,
216
- exception = "" .join (exc_traceback [- last_context_line :]),
230
+ exception = "" .join (
231
+ exc_group_traceback if exc_group_traceback else exc_traceback
232
+ ),
217
233
)
218
234
out = fastapi .responses .JSONResponse (
219
235
status_code = fastapi .status .HTTP_500_INTERNAL_SERVER_ERROR ,
0 commit comments