Package org.instancio.internal.util
Class Fail
java.lang.Object
org.instancio.internal.util.Fail
Utility class for constructing exceptions.
-
Method Summary
Modifier and TypeMethodDescriptionwithFataInternalError
(String msg, Object... args) Creates an exception due to an internal error.static InstancioException
withInternalError
(Throwable cause) Wraps given exception in anInstancioException
, including a message to request a bug report submission.static InstancioApiException
withUsageError
(String msg, Object... args) Creates an exception caused by incorrect usage of the API.
-
Method Details
-
withInternalError
Wraps given exception in anInstancioException
, 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
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 theargs
args
- error message arguments- Returns:
- an exception to be propagated to the user
-
withFataInternalError
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 theargs
args
- error message arguments- Returns:
- an exception to be propagated to the user
-