raannakasturi commited on
Commit
c3ef24f
·
1 Parent(s): 4b0577b

Add error handling for data fetching in fetch_paper_data_with_category function

Browse files
Files changed (1) hide show
  1. fetch_data.py +7 -3
fetch_data.py CHANGED
@@ -59,9 +59,13 @@ def fetch_paper_data_with_category(cat_ids_api_key):
59
  if cat_ids:
60
  for category, ids in cat_ids.items():
61
  print(f"Fetching data for category: {category}")
62
- paper_data = fetch_paper_data_concurrently(ids['ids'])
63
- if paper_data:
64
- data[category] = paper_data
 
 
 
 
65
  return json.dumps(data, indent=4, ensure_ascii=False)
66
  except Exception as e:
67
  print(f"Exception while fetching paper data by category: {str(e)}")
 
59
  if cat_ids:
60
  for category, ids in cat_ids.items():
61
  print(f"Fetching data for category: {category}")
62
+ try:
63
+ paper_data = fetch_paper_data_concurrently(ids['ids'])
64
+ if paper_data:
65
+ data[category] = paper_data
66
+ except Exception as e:
67
+ print(f"Error fetching data for category {category}: {str(e)}")
68
+ continue
69
  return json.dumps(data, indent=4, ensure_ascii=False)
70
  except Exception as e:
71
  print(f"Exception while fetching paper data by category: {str(e)}")