From 24d242513c5279dd25dc39d08a7f852b51486199 Mon Sep 17 00:00:00 2001 From: nzcer Date: Mon, 11 Dec 2023 16:39:46 +0800 Subject: [PATCH] fix: add exception handling --- src/main/java/cn/nzcer/odapi/cron/SyncDataBase.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/cn/nzcer/odapi/cron/SyncDataBase.java b/src/main/java/cn/nzcer/odapi/cron/SyncDataBase.java index 520b3e6..636eeee 100644 --- a/src/main/java/cn/nzcer/odapi/cron/SyncDataBase.java +++ b/src/main/java/cn/nzcer/odapi/cron/SyncDataBase.java @@ -117,7 +117,13 @@ public Set parseRepo(String url) throws IOException { public Set parseRepo(String url, int count) throws IOException { JSONObject jsonObject = NetUtil.doGet(url); Set repoNames = new HashSet<>(); - JSONArray jsonArray = jsonObject.getJSONArray("data"); + JSONArray jsonArray = null; + try { + jsonArray = jsonObject.getJSONArray("data"); + } catch (Exception e) { + e.printStackTrace(); + return repoNames; + } int cnt = 0; for (int i = 0; i < jsonArray.size(); i++) { String repoName = jsonArray.getJSONObject(i).getJSONObject("item").getString("name");