Package com.storedobject.common
Class SORuntimeException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.storedobject.common.SORuntimeException
- All Implemented Interfaces:
EndUserMessage,Serializable
- Direct Known Subclasses:
Database_Message,Design_Error,Error_Running_SQL,Get_Not_Allowed,Serial_Not_Generated,Set_Not_Allowed,SOClassError,SOError
A custom runtime exception class that provides enhanced error details and user-friendly messages.
It implements the
EndUserMessage interface to support messages targeted at end users
for better readability and clarity.
- Supports chaining of exceptions and integrates with the
SOExceptionclass for consistent end-user messaging. - Provides utility methods for extracting detailed stack traces and root cause analysis.
- Overridden methods aim to produce structurally formatted messages derived from the exception hierarchy and root causes.
- Author:
- Syam
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for the SORuntimeException class.SORuntimeException(String message) Constructs a new SORuntimeException instance with the specified detail message.SORuntimeException(String message, Throwable cause) Constructs a new SORuntimeException instance with the specified detail message and cause.SORuntimeException(Throwable cause) Constructs a new SORuntimeException instance with the specified cause. -
Method Summary
Modifier and TypeMethodDescriptionprotected StringRetrieves a custom message associated with this exception.Get the message.getTrace()Retrieves the full or partial stack trace of this exception or its root cause as a string.static StringRetrieves the stack trace of the specified thread as a string.static StringRetrieves the stack trace of the specified thread as a string.static StringRetrieves a string representation of the stack trace for the givenThrowable.static StringRetrieves a string representation of the stack trace for a givenThrowable.toString()Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Constructor Details
-
SORuntimeException
public SORuntimeException()Default constructor for the SORuntimeException class. This constructor initializes a new instance of the exception without any custom message or cause. -
SORuntimeException
Constructs a new SORuntimeException instance with the specified detail message.- Parameters:
message- the detail message that explains the reason for the exception
-
SORuntimeException
Constructs a new SORuntimeException instance with the specified cause.- Parameters:
cause- the underlying cause of the exception, which can be null
-
SORuntimeException
Constructs a new SORuntimeException instance with the specified detail message and cause.- Parameters:
message- the detail message that provides additional context or explanation for the exceptioncause- the underlying cause of the exception, typically another Throwable, which can be null
-
-
Method Details
-
getEndUserMessage
Description copied from interface:EndUserMessageGet the message.- Specified by:
getEndUserMessagein interfaceEndUserMessage- Returns:
- The message that is for the end-users to read.
-
getMessage
- Overrides:
getMessagein classThrowable
-
getCustomMessage
Retrieves a custom message associated with this exception. This method can be overridden by subclasses to provide specific custom messages based on the exception's context.- Returns:
- the custom message as a string, or null if no custom message is provided
-
toString
-
getTrace
Retrieves the full or partial stack trace of this exception or its root cause as a string. This method determines the trace based on whether this exception has a cause or not, and delegates to thegetTrace(Throwable, boolean)method.- Returns:
- a string representation of the stack trace, starting from either the root cause or this exception
-
getTrace
Retrieves a string representation of the stack trace for the givenThrowable. The stack trace may represent either the root cause or the specified exception depending on the implementation. -
getTrace
Retrieves a string representation of the stack trace for a givenThrowable. The representation can include either the full stack trace with all causes or only the root cause, based on the specified flag.- Parameters:
t- theThrowablewhose stack trace needs to be retrieved; must not be nullfull- a boolean flag indicating whether to include the full stack trace (true) or only the root cause (false)- Returns:
- a string representation of the stack trace, either for the full exception chain
or just the root cause, depending on the
fullparameter
-
getTrace
Retrieves the stack trace of the specified thread as a string. The stack trace is prefixed with a default title "Stack Trace".- Parameters:
thread- theThreadwhose stack trace needs to be retrieved; must not be null- Returns:
- a string representation of the stack trace for the specified thread, prefixed with the default title
-
getTrace
Retrieves the stack trace of the specified thread as a string. The stack trace is prefixed with the given title.- Parameters:
thread- theThreadwhose stack trace needs to be retrieved; must not be nulltitle- the title to display as the prefix of the stack trace; must not be null or empty- Returns:
- a string representation of the stack trace for the specified thread, prefixed with the given title
-