AnyLogic
Expand
Font size

@AnyLogicInternalAPI
public final class UtilitiesError
extends Object

Method Summary

Modifier and TypeMethodDescription
static <T extends Throwable>
T
dropLastFromStack(T throwable)
Removes last element from stack trace of the given throwable
This method may be used in private check/ensure-methods
static <T extends Throwable>
T
dropLastFromStack(T throwable, int count)
Removes last elements from stack trace of the given throwable
This method may be used in private check/ensure-methods
static RuntimeExceptionerror(String errorText) 
static RuntimeExceptionerror(String errorTextFormat, Object... args) 
static RuntimeExceptionerror(Throwable cause, String errorText) 
static RuntimeExceptionerror(Throwable cause, String errorTextFormat, Object... args)
Creates and throws new RuntimeException with message using format syntax like in String.format(String, Object...) method
static StringformatSafe(String messageFormat, Object... messageArgs)
static Class<?>getClassSafe(Object obj) 
static RuntimeExceptiongetRuntimeException(Throwable e) 
static voidprocessThreadDeath(Throwable e)
Rethrows e if it is ThreadDeath
static StringtoStringSafe(Object o) 
static StringtoStringStackTrace(Throwable e) 
static StringtoStringWithCauses(Throwable e)
Returns toString of the given throwable and all its causers

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

error

public static RuntimeException error(String errorText)
See Also:

error

public static RuntimeException error(Throwable cause,
 String errorText)
See Also:

error

public static RuntimeException error(String errorTextFormat,
 Object... args)
See Also:

error

public static RuntimeException error(Throwable cause,
 String errorTextFormat,
 Object... args)
Creates and throws new RuntimeException with message using format syntax like in String.format(String, Object...) method
Parameters:
cause - the exception which caused this error to happen
Returns:
this method is declared to return RuntimeException just for convenience (it may be useful sometimes to write throw error(...) to tell compiler that the next line of code will not happen to execute), but it will never return it.
See Also:

getRuntimeException

public static RuntimeException getRuntimeException(Throwable e)

dropLastFromStack

public static <T extends Throwable> T dropLastFromStack(T throwable)
Removes last element from stack trace of the given throwable
This method may be used in private check/ensure-methods
Type Parameters:
T -
Parameters:
throwable -
Returns:
given throwable, for convenience

dropLastFromStack

public static <T extends Throwable> T dropLastFromStack(T throwable,
 int count)
Removes last elements from stack trace of the given throwable
This method may be used in private check/ensure-methods
Type Parameters:
T -
Parameters:
throwable -
Returns:
given throwable, for convenience

processThreadDeath

@AnyLogicInternalAPI
public static void processThreadDeath(Throwable e)
Rethrows e if it is ThreadDeath
Parameters:
e -
See Also:
ThreadDeath

formatSafe

public static String formatSafe(String messageFormat,
 Object... messageArgs)
Safe analog of String.format(String, Object...). Doesn't fail in case of message format errors.

toStringStackTrace

public static String toStringStackTrace(Throwable e)
Returns:
stack trace as a string

toStringWithCauses

public static String toStringWithCauses(Throwable e)
Returns toString of the given throwable and all its causers
Parameters:
e -
Returns:
toString of the given throwable and all its causers

toStringSafe

public static String toStringSafe(Object o)

getClassSafe

public static Class<?> getClassSafe(Object obj)