Interface IMixinErrorHandler


  • public interface IMixinErrorHandler
    Interface for objects which want to perform custom behaviour when fatal mixin errors occur. For example displaying a user-friendly error message
    • Method Detail

      • onPrepareError

        IMixinErrorHandler.ErrorAction onPrepareError​(IMixinConfig config,
                                                      java.lang.Throwable th,
                                                      IMixinInfo mixin,
                                                      IMixinErrorHandler.ErrorAction action)
        Called when an error occurs whilst initialising a mixin config. This allows the plugin to display more user-friendly error messages if required.

        By default, when a critical error occurs the mixin processor will raise a warning if the config is not marked as "required" and will throw an Error if it is. This behaviour can be altered by returning different values from this method.

        The original throwable which was caught is passed in via the th parameter and the default action is passed in to the action parameter. A plugin can choose to output a friendly message but leave the original behaviour intact (by returning null or returning action directly. Alternatively it may throw a different exception or error, or can reduce the severity of the error by returning a different IMixinErrorHandler.ErrorAction.

        Parameters:
        config - Config being prepared when the error occurred
        th - Throwable which was caught
        mixin - Mixin which was being applied at the time of the error
        action - Default action
        Returns:
        null to perform the default action (or return action) or new action to take
      • onApplyError

        IMixinErrorHandler.ErrorAction onApplyError​(java.lang.String targetClassName,
                                                    java.lang.Throwable th,
                                                    IMixinInfo mixin,
                                                    IMixinErrorHandler.ErrorAction action)
        Called when an error occurs applying a mixin. This allows the plugin to display more user-friendly error messages if required.

        By default, when a critical error occurs the mixin processor will raise a warning if the config is not marked as "required" and will throw an Error if it is. This behaviour can be altered by returning different values from this method.

        The original throwable which was caught is passed in via the th parameter and the default action is passed in to the action parameter. A plugin can choose to output a friendly message but leave the original behaviour intact (by returning null or returning action directly. Alternatively it may throw a different exception or error, or can reduce the severity of the error by returning a different IMixinErrorHandler.ErrorAction.

        Parameters:
        targetClassName - Class being transformed when the error occurred
        th - Throwable which was caught
        mixin - Mixin which was being applied at the time of the error
        action - Default action
        Returns:
        null to perform the default action (or return action) or new action to take