Class RuntimeErrorManager

java.lang.Object
org.skriptlang.skript.log.runtime.RuntimeErrorManager
All Implemented Interfaces:
Closeable, AutoCloseable

public class RuntimeErrorManager extends Object implements Closeable
Handles passing runtime errors between producers and consumers via a frame collection system.
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 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

      @Internal public static RuntimeErrorManager getInstance()
      Prefer using Skript.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

      public void error(@NotNull @NotNull RuntimeError error)
      Emits a warning or error depending on severity. Errors are passed to their respective Frames for processing.
      Parameters:
      error - The error to emit.
    • getErrorFrame

      public Frame getErrorFrame()
      Returns:
      The frame containing emitted errors.
    • getWarningFrame

      public Frame getWarningFrame()
      Returns:
      The frame containing emitted warnings.
    • addConsumer

      public void addConsumer(RuntimeErrorConsumer consumer)
      Adds a RuntimeErrorConsumer 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

      public void removeConsumer(RuntimeErrorConsumer consumer)
      Removes a RuntimeErrorConsumer from the tracked list.
      Parameters:
      consumer - The consumer to remove.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable