Class ErrorResultException
- All Implemented Interfaces:
Serializable
This exception is typically thrown by function tools (e.g.,
@Tool-annotated methods) to report structured error results, such as
error codes, descriptions, or additional context, back to the caller (e.g.,
an AI provider or orchestration layer) in a machine-readable format rather
than plain text.
The provided error payload (via the message parameter) is serialized
to a JSON string using a default ObjectMapper instance. If
serialization fails, the payload is converted to a string using
Objects.toString(Object).
- Since:
- 1.3.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionErrorResultException(Object message) Creates a new exception with a message that is the JSON representation of the given object.ErrorResultException(Object message, Exception e) Creates a new exception with a message that is the JSON representation of the given object, combined with additional error details from another exception.ErrorResultException(String message) Creates a new exception using the given string directly as the message, without JSON serialization. -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
ErrorResultException
Creates a new exception with a message that is the JSON representation of the given object.This constructor is used when the error details are provided as an object, which will be serialized to a JSON string using a default
ObjectMapper. The resulting JSON string becomes the exception's message.- Parameters:
message- the object describing the error result; serialized to JSON and used as this exception's message
-
ErrorResultException
Creates a new exception using the given string directly as the message, without JSON serialization.Use this constructor when the error message is already a plain string (e.g., already JSON-formatted, or intentionally plain text) and does not need to be serialized via
ObjectMapper.- Parameters:
message- the exception message, used as-is
-
ErrorResultException
Creates a new exception with a message that is the JSON representation of the given object, combined with additional error details from another exception.This constructor is used when an error occurs during processing and you want to include both the structured error result (serialized to JSON) and the details of the underlying exception.
- Parameters:
message- the object describing the error result; serialized to JSON and included in the exception messagee- the underlying exception whose details are included in the exception message
-
-
Method Details
-
message
Constructs a detailed error message by combining the provided message object and exception details.If the
messageis aString, it is used as-is. Otherwise, the method attempts to serialize themessageobject to a JSON string using a defaultObjectMapper. If serialization fails, themessageobject is converted to a string usingObjects.toString(Object).If an exception is provided, its details are also appended to the resulting message.
- Parameters:
message- the object describing the error result; can be a string or any serializable objecte- the exception whose details are included in the error message (optional)- Returns:
- a formatted error message containing the serialized error result and exception details
-