@@ -12,6 +12,9 @@ def is_processing(result):
12
12
"""Checks if the API result indicates backend processing."""
13
13
return isinstance (result , dict ) and result .get ("result" ) == "processing"
14
14
15
+ def has_error (result ):
16
+ """Checks if the API result indicates an error."""
17
+ return isinstance (result , dict ) and "error" in result
15
18
16
19
def _get_perp_market_symbol_display (market_index ):
17
20
"""Safely get the display string for a perp market index."""
@@ -190,6 +193,8 @@ def health_page():
190
193
191
194
if is_processing (largest_perp_positions ):
192
195
is_still_processing = True
196
+ elif has_error (largest_perp_positions ):
197
+ st .error (f"Error fetching largest perp positions: { largest_perp_positions .get ('error' , 'Unknown error' )} " )
193
198
else :
194
199
# Convert to DataFrame and add pagination
195
200
df = pd .DataFrame (largest_perp_positions )
@@ -236,6 +241,8 @@ def health_page():
236
241
237
242
if is_processing (most_levered_positions ):
238
243
is_still_processing = True
244
+ elif has_error (most_levered_positions ):
245
+ st .error (f"Error fetching most levered perp positions: { most_levered_positions .get ('error' , 'Unknown error' )} " )
239
246
else :
240
247
# Format market index in most_levered_positions too
241
248
most_levered_df = pd .DataFrame (most_levered_positions )
@@ -310,6 +317,8 @@ def health_page():
310
317
311
318
if is_processing (largest_spot_borrows ):
312
319
is_still_processing = True
320
+ elif has_error (largest_spot_borrows ):
321
+ st .error (f"Error fetching largest spot borrows: { largest_spot_borrows .get ('error' , 'Unknown error' )} " )
313
322
else :
314
323
# Convert to dataframe and add market symbols
315
324
spot_df = pd .DataFrame (largest_spot_borrows )
@@ -356,6 +365,8 @@ def health_page():
356
365
)
357
366
if is_processing (most_levered_borrows ):
358
367
is_still_processing = True
368
+ elif has_error (most_levered_borrows ):
369
+ st .error (f"Error fetching most levered spot borrows: { most_levered_borrows .get ('error' , 'Unknown error' )} " )
359
370
else :
360
371
# Convert to dataframe and add market symbols
361
372
levered_spot_df = pd .DataFrame (most_levered_borrows )
0 commit comments