3636# Tests monkeypatch this path; keep in sync with utils.export_state_store.
3737_STATE_FILE = EXPORT_STATE_FILE
3838
39+ _EXPORT_ERRORS = (
40+ json .JSONDecodeError ,
41+ KeyError ,
42+ ValueError ,
43+ OSError ,
44+ FileNotFoundError ,
45+ )
46+
3947
4048def _state_lock () -> Any :
4149 return export_state_lock (_STATE_FILE )
@@ -162,7 +170,7 @@ def bulk_export() -> FlaskReturn:
162170 )
163171 new_sessions_map [sid ] = sess_info .get ("modified" , 0 )
164172 count += 1
165- except Exception as e :
173+ except _EXPORT_ERRORS as e :
166174 current_app .logger .warning (
167175 "Failed to export %s: %s" , sid [:10 ], e
168176 )
@@ -224,7 +232,7 @@ def bulk_export() -> FlaskReturn:
224232 )
225233 new_sessions_map [sid ] = sess_info .get ("modified" , 0 )
226234 count += 1
227- except Exception as e :
235+ except _EXPORT_ERRORS as e :
228236 current_app .logger .warning (
229237 "Failed to export %s: %s" , sid [:10 ], e
230238 )
@@ -287,7 +295,7 @@ def export_session(project_name: str, session_id: str) -> FlaskReturn:
287295 fmt = request .args .get ("format" , "md" )
288296 try :
289297 session = parse_session (filepath )
290- except Exception :
298+ except _EXPORT_ERRORS :
291299 current_app .logger .exception (
292300 "Failed to parse session %s for export" , session_id
293301 )
@@ -307,7 +315,7 @@ def export_session(project_name: str, session_id: str) -> FlaskReturn:
307315
308316 try :
309317 stats = compute_stats (session )
310- except Exception :
318+ except _EXPORT_ERRORS :
311319 current_app .logger .exception (
312320 "Failed to compute stats for export %s" , session_id
313321 )
0 commit comments