@GwtCompatible public final class Exceptions extends Object
Config class
directly.
The ...Exception(...) methods all return exceptions of the type
indicated by the method name with their stack traces cleaned up. This feature
is described in the documentation of the Check class.
The stack trace cleaning is implemented by removing from the top of the stack
trace all stack frames belonging to methods that are part of the Better
Checks library. A method is defined to be part of the Better Checks library
iff it belongs to a class that is located in the base package of the library
(ch.trick17.betterchecks) or one of its subpackages.
Exceptionally, for testing purposes, classes ending in "Test" are not
considered to be part of the library.
| Modifier and Type | Method and Description |
|---|---|
static String |
defaultArgName()
A convenience method that returns the default argument name from the
configuration.
|
static String |
formatMsg(MessageType msgType,
boolean inverted,
Object... msgArgs)
Formats an exception message using the format corresponding to the given
message type and the given message arguments.
|
static IllegalArgumentException |
illegalArgumentException(MessageType msgType,
boolean inverted,
Object[] msgArgs)
Returns an
IllegalArgumentException with a message formatted
using the format corresponding to the given message type and the given
message arguments. |
static IllegalArgumentException |
illegalArgumentException(MessageType msgType,
boolean inverted,
Object[] msgArgs,
Throwable cause)
Returns an
IllegalArgumentException with a message formatted
using the format corresponding to the given message type and the given
message arguments. |
static IllegalArgumentException |
illegalArgumentException(String message)
Returns an
IllegalArgumentException with the given exception
message and a cleaned-up stack trace (if enabled). |
static IllegalStateException |
illegalStateException(String message)
Returns an
IllegalStateException with the given exception message
and a cleaned-up stack trace (if enabled). |
public static IllegalArgumentException illegalArgumentException(String message)
IllegalArgumentException with the given exception
message and a cleaned-up stack trace (if enabled).message - The exception messagepublic static IllegalArgumentException illegalArgumentException(MessageType msgType, boolean inverted, Object[] msgArgs)
IllegalArgumentException with a message formatted
using the format corresponding to the given message type and the given
message arguments. If inverted is true, the
inverted message format will be used. Also, the stack trace of the
exception will be cleaned (if enabled).
See Config.getMessageFormat(MessageType, boolean) for more
information about exception message formats.
msgType - The message type indicating the message format to useinverted - If true, the inverted format is usedmsgArgs - The message argumentspublic static IllegalArgumentException illegalArgumentException(MessageType msgType, boolean inverted, Object[] msgArgs, Throwable cause)
IllegalArgumentException with a message formatted
using the format corresponding to the given message type and the given
message arguments. If inverted is true, the
inverted message format will be used. Also, the cause of the message is
set to the one given and the stack trace of the exception will be cleaned
(if enabled).
See Config.getMessageFormat(MessageType, boolean) for more
information about exception message formats.
msgType - The message type indicating the message format to useinverted - If true, the inverted format is usedmsgArgs - The message argumentscause - The cause for the exceptionpublic static IllegalStateException illegalStateException(String message)
IllegalStateException with the given exception message
and a cleaned-up stack trace (if enabled).message - The exception messagepublic static String formatMsg(MessageType msgType, boolean inverted, Object... msgArgs)
inverted is
true, the inverted message format will be used.msgType - The message type indicating the message format to useinverted - If true, the inverted format is usedmsgArgs - The message argumentspublic static String defaultArgName()
Config.getDefaultArgumentName()Copyright © 2012–2017 Michael Faes. All rights reserved.