Class RuntimeErrorManager
java.lang.Object
org.skriptlang.skript.log.runtime.RuntimeErrorManager
- All Implemented Interfaces:
Closeable
,AutoCloseable
Handles passing runtime errors between producers and consumers via a frame collection system.
The manager should be treated as a singleton and accessed via
The manager should be treated as a singleton and accessed via
getInstance()
or Skript.getRuntimeErrorManager()
. Changing the frame length or limits requires edits to the
SkriptConfig
values and a call to refresh()
. Reloading the config will automatically
call refresh()
.- See Also:
-
Constructor Summary
ConstructorDescriptionRuntimeErrorManager
(int frameLength, Frame.FrameLimit errorLimits, Frame.FrameLimit warningLimits) Creates a new error manager, which also creates its own frames. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConsumer
(RuntimeErrorConsumer consumer) Adds aRuntimeErrorConsumer
that will receive the emitted errors and frame output data.void
close()
void
error
(@NotNull RuntimeError error) Emits a warning or error depending on severity.static RuntimeErrorManager
Prefer usingSkript.getRuntimeErrorManager()
instead.static void
refresh()
Refreshes the runtime error manager for Skript, pulling from the config values.void
removeConsumer
(RuntimeErrorConsumer consumer) Removes aRuntimeErrorConsumer
from the tracked list.
-
Constructor Details
-
RuntimeErrorManager
public RuntimeErrorManager(int frameLength, Frame.FrameLimit errorLimits, Frame.FrameLimit warningLimits) Creates a new error manager, which also creates its own frames.
Must be closed when no longer being used.- Parameters:
frameLength
- The length of a frame in ticks.errorLimits
- The limits to the error frame.warningLimits
- The limits to the warning frame.
-
-
Method Details
-
getInstance
Prefer usingSkript.getRuntimeErrorManager()
instead.- Returns:
- The singleton instance of the runtime error manager.
-
refresh
public static void refresh()Refreshes the runtime error manager for Skript, pulling from the config values. Tracked consumers are maintained during refreshes. -
error
Emits a warning or error depending on severity. Errors are passed to their respectiveFrame
s for processing.- Parameters:
error
- The error to emit.
-
getErrorFrame
- Returns:
- The frame containing emitted errors.
-
getWarningFrame
- Returns:
- The frame containing emitted warnings.
-
addConsumer
Adds aRuntimeErrorConsumer
that will receive the emitted errors and frame output data. Consumers will be maintained when the manager is refreshed.- Parameters:
consumer
- The consumer to add.
-
removeConsumer
Removes aRuntimeErrorConsumer
from the tracked list.- Parameters:
consumer
- The consumer to remove.
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-