Package com.fauna.response
Class ErrorInfo
- java.lang.Object
-
- com.fauna.response.ErrorInfo
-
public class ErrorInfo extends java.lang.Object
This class will encapsulate all the information Fauna returns about errors including constraint failures, and abort data, for now it just has the code and message.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ErrorInfo.Builder
-
Constructor Summary
Constructors Constructor Description ErrorInfo(java.lang.String code, java.lang.String message, ConstraintFailure[] constraintFailures, com.fasterxml.jackson.core.TreeNode abort)
Initializes a new ErrorInfo.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ErrorInfo.Builder
builder()
A utility method to instantiate an empty builder.<T> java.util.Optional<T>
getAbort(java.lang.Class<T> abortDataClass)
Parses the abort data into the provided class.java.util.Optional<com.fasterxml.jackson.core.TreeNode>
getAbortJson()
Gets the user-defined abort error message as a JSON node.java.lang.String
getCode()
Gets the Fauna error code.java.util.Optional<ConstraintFailure[]>
getConstraintFailures()
Gets the constraint failures.java.lang.String
getMessage()
Gets the error message.static ErrorInfo
parse(com.fasterxml.jackson.core.JsonParser parser)
Builds a new ErrorInfo from a JsonParser.
-
-
-
Constructor Detail
-
ErrorInfo
public ErrorInfo(java.lang.String code, java.lang.String message, ConstraintFailure[] constraintFailures, com.fasterxml.jackson.core.TreeNode abort)
Initializes a new ErrorInfo.- Parameters:
code
- The Fauna error code.message
- A short, human-readable description of the error.constraintFailures
- The constraint failures for the error, if any. Only present if the error code is `constraint_failure`.abort
- A user-defined error message passed using an FQL `abort()` method call. Only present if the error code is `abort`.
-
-
Method Detail
-
builder
public static ErrorInfo.Builder builder()
A utility method to instantiate an empty builder.- Returns:
- A new builder
-
parse
public static ErrorInfo parse(com.fasterxml.jackson.core.JsonParser parser) throws java.io.IOException
Builds a new ErrorInfo from a JsonParser.- Parameters:
parser
- The JsonParser to read.- Returns:
- A new ErrorInfo instance.
- Throws:
java.io.IOException
- Thrown on errors reading from the parser.
-
getCode
public java.lang.String getCode()
Gets the Fauna error code.- Returns:
- A string representing the Fauna error code.
-
getMessage
public java.lang.String getMessage()
Gets the error message.- Returns:
- A string representing the error message.
-
getConstraintFailures
public java.util.Optional<ConstraintFailure[]> getConstraintFailures()
Gets the constraint failures.- Returns:
- An optional containing the constraint failures.
-
getAbortJson
public java.util.Optional<com.fasterxml.jackson.core.TreeNode> getAbortJson()
Gets the user-defined abort error message as a JSON node.- Returns:
- An optional TreeNode with the abort data.
-
getAbort
public <T> java.util.Optional<T> getAbort(java.lang.Class<T> abortDataClass)
Parses the abort data into the provided class.- Type Parameters:
T
- The type to decode into.- Parameters:
abortDataClass
- The class to decode into.- Returns:
- An instance of the provided type.
-
-