-
-
Notifications
You must be signed in to change notification settings - Fork 407
Better runtime error filtering #8195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sovdeeth
merged 7 commits into
SkriptLang:dev/feature
from
sovdeeth:feature/better-runtime-error-filtering
Oct 1, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
80612cc
make filtering consumer-specific.
sovdeeth 4fd4766
better remove()
sovdeeth f63174e
Merge branch 'dev/feature' into feature/better-runtime-error-filtering
Absolutionism 6c5f037
Requested Changes
sovdeeth c03e593
Merge branch 'dev/feature' into feature/better-runtime-error-filtering
sovdeeth 0a8b735
avoid null
sovdeeth cb0a136
Merge branch 'feature/better-runtime-error-filtering' of https://gith…
sovdeeth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/org/skriptlang/skript/log/runtime/RuntimeErrorFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package org.skriptlang.skript.log.runtime; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.logging.Level; | ||
|
||
/** | ||
* Handles filtering of runtime errors based on their level and predefined limits. | ||
* Uses the concept of 'frames' to track the number of errors and warnings that are allowed in a given period. | ||
* Use {@link #test(RuntimeError)} to determine if a runtime error should be printed or not. | ||
* Printing the frame outputs can be done via {@link #getErrorFrame()} and {@link #getWarningFrame()}. | ||
*/ | ||
public class RuntimeErrorFilter { | ||
|
||
/** | ||
* A filter that does not filter anything, allowing all errors and warnings to be printed. | ||
* Modifications to its limits will do nothing, and the returned frames will hold no relevant data. | ||
*/ | ||
public static final RuntimeErrorFilter NO_FILTER = new RuntimeErrorFilter( | ||
new Frame.FrameLimit(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE), | ||
new Frame.FrameLimit(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE) | ||
) { | ||
@Override | ||
public boolean test(@NotNull RuntimeError error) { | ||
return true; | ||
} | ||
}; | ||
|
||
private Frame errorFrame, warningFrame; | ||
|
||
public RuntimeErrorFilter(Frame.FrameLimit errorFrameLimits, Frame.FrameLimit warningFrameLimits) { | ||
this.errorFrame = new Frame(errorFrameLimits); | ||
this.warningFrame = new Frame(warningFrameLimits); | ||
} | ||
|
||
/** | ||
* Tests whether a runtime error should be printed or not. | ||
* @param error True if it should be printed, false if not. | ||
*/ | ||
public boolean test(@NotNull RuntimeError error) { | ||
// print if < limit | ||
return (error.level() == Level.SEVERE && errorFrame.add(error)) | ||
|| (error.level() == Level.WARNING && warningFrame.add(error)); | ||
} | ||
|
||
public void setErrorFrameLimits(Frame.FrameLimit limits) { | ||
this.errorFrame = new Frame(limits); | ||
} | ||
|
||
public void setWarningFrameLimits(Frame.FrameLimit limits) { | ||
this.warningFrame = new Frame(limits); | ||
} | ||
|
||
/** | ||
* @return The frame containing emitted errors. | ||
*/ | ||
public Frame getErrorFrame() { | ||
return errorFrame; | ||
} | ||
|
||
/** | ||
* @return The frame containing emitted warnings. | ||
*/ | ||
public Frame getWarningFrame() { | ||
return warningFrame; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.