fix: narrow catch exception type in ParserCreate.java

Replace 5 instances of `catch (Exception ignored)` with
`catch (IllegalStateException ignored)` around matcher.group() calls,
since that method only throws IllegalStateException when a named group
does not exist.
This commit is contained in:
yukaidi
2026-05-29 06:27:51 +08:00
parent 206981d4b4
commit 86b9c43b8b

View File

@@ -81,7 +81,7 @@ public class ParserCreate {
if (shareKey != null) { if (shareKey != null) {
shareLinkInfo.setShareKey(shareKey); shareLinkInfo.setShareKey(shareKey);
} }
} catch (Exception ignored) {} } catch (IllegalStateException ignored) {}
// 提取密码 // 提取密码
try { try {
@@ -89,7 +89,7 @@ public class ParserCreate {
if (StringUtils.isNotEmpty(pwd)) { if (StringUtils.isNotEmpty(pwd)) {
shareLinkInfo.setSharePassword(pwd); shareLinkInfo.setSharePassword(pwd);
} }
} catch (Exception ignored) {} } catch (IllegalStateException ignored) {}
// 设置标准URL // 设置标准URL
if (customParserConfig.getStandardUrlTemplate() != null) { if (customParserConfig.getStandardUrlTemplate() != null) {
@@ -133,7 +133,7 @@ public class ParserCreate {
shareLinkInfo.setSharePassword(pwd); shareLinkInfo.setSharePassword(pwd);
} }
standardUrl = standardUrl.replace("{pwd}", pwd); standardUrl = standardUrl.replace("{pwd}", pwd);
} catch (Exception ignored) {} } catch (IllegalStateException ignored) {}
shareLinkInfo.setShareUrl(shareUrl); shareLinkInfo.setShareUrl(shareUrl);
shareLinkInfo.setShareKey(shareKey); shareLinkInfo.setShareKey(shareKey);
@@ -266,14 +266,14 @@ public class ParserCreate {
if (shareKey != null) { if (shareKey != null) {
shareLinkInfo.setShareKey(shareKey); shareLinkInfo.setShareKey(shareKey);
} }
} catch (Exception ignored) {} } catch (IllegalStateException ignored) {}
try { try {
String password = matcher.group("PWD"); String password = matcher.group("PWD");
if (password != null) { if (password != null) {
shareLinkInfo.setSharePassword(password); shareLinkInfo.setSharePassword(password);
} }
} catch (Exception ignored) {} } catch (IllegalStateException ignored) {}
// 设置标准URL如果有模板 // 设置标准URL如果有模板
if (customConfig.getStandardUrlTemplate() != null) { if (customConfig.getStandardUrlTemplate() != null) {