mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-05 02:58:20 +08:00
fix: Try to ignore errors when applying replacer
This commit is contained in:
+2
-1
@@ -39,7 +39,8 @@ public abstract class ContentInserter<RECEIVER> implements Comparable<ContentIns
|
||||
@NotNull Insertable<RECEIVER, ?> insertions) {
|
||||
Matcher matcher = matcher(line);
|
||||
if (!matcher.matches()) return null;
|
||||
if (!insertions.inserting(extractID(matcher))) return Collections.emptyList();
|
||||
String id = extractID(matcher);
|
||||
if (id == null || !insertions.inserting(id)) return Collections.emptyList();
|
||||
return get(receiver, matcher, insertions);
|
||||
}
|
||||
|
||||
|
||||
+7
-2
@@ -47,8 +47,13 @@ public abstract class ContentReplacer<RECEIVER> implements Comparable<ContentRep
|
||||
Matcher matcher = matcher(text);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
while (matcher.find()) {
|
||||
String replaced = get(receiver, matcher);
|
||||
matcher.appendReplacement(sb, replaced == null ? "" : replaced);
|
||||
try {
|
||||
String replaced = get(receiver, matcher);
|
||||
matcher.appendReplacement(sb, replaced == null ? "" : replaced);
|
||||
} catch (Exception ex) {
|
||||
// Do nothing if exception occurred.
|
||||
ex.printStackTrace(); // for debug
|
||||
}
|
||||
}
|
||||
matcher.appendTail(sb);
|
||||
return sb.toString();
|
||||
|
||||
Reference in New Issue
Block a user