Class Fail

java.lang.Object
org.instancio.internal.util.Fail

public final class Fail extends Object
Utility class for constructing exceptions.
  • Method Details

    • withInternalError

      public static InstancioException withInternalError(Throwable cause)
      Wraps given exception in an InstancioException, including a message to request a bug report submission.

      This exception will not be propagated to the user unless SystemProperties.FAIL_ON_ERROR is enabled.

      Parameters:
      cause - of an error
      Returns:
      a wrapped exception with a message requesting a bug report
    • withUsageError

      public static InstancioApiException withUsageError(String msg, Object... args)
      Creates an exception caused by incorrect usage of the API. This exception should be propagated to the user.

      If the last argument is an instance of Throwable, it will be used as the cause of the returned exception.

      Parameters:
      msg - an error message, allows '%s' placeholders for the args
      args - error message arguments
      Returns:
      an exception to be propagated to the user
    • withFataInternalError

      public static InstancioTerminatingException withFataInternalError(String msg, Object... args)
      Creates an exception due to an internal error. This exception should be propagated to the user.

      If the last argument is an instance of Throwable, it will be used as the cause of the returned exception.

      Parameters:
      msg - an error message, allows '%s' placeholders for the args
      args - error message arguments
      Returns:
      an exception to be propagated to the user