Package com.atlassian.adf.model.ex
Class AdfException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- com.atlassian.adf.model.ex.AdfException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AdfException.MissingType,AdfException.PropertyException,AdfException.UnexpectedRuntimeException,AdfException.UnsupportedEnumValue,BorderException,IndentationException,MarkException,NodeException
public abstract class AdfException extends RuntimeException
An exception reporting a problem with the structure of an ADF document.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAdfException.DuplicatePropertyThrown to indicate the error of attempting to add the same key to the map representation of a node more than one time.static classAdfException.EmptyPropertyThrown to indicate that a required string value was specified as an empty string.static classAdfException.InvalidURIUsed as a runtime replacement forURISyntaxExceptionwhen a parameter value that must be a valid URI is checked.static classAdfException.MissingPropertyThrown to indicate that a required field or attribute was not provided.static classAdfException.MissingTypeThrown for any node or mark that fails to specify atypevalue.static classAdfException.PropertyExceptionThrown to indicate that there is something wrong with a field (those values placed directly at the top level of a node or mark) or attribute (those placed within theattrsobject).static classAdfException.UnexpectedRuntimeExceptionUsed to wrap other runtime exceptions as anAdfException, primarily so that theerror pathcan potentially be provided for it.static classAdfException.UnsupportedEnumValueThrown when a limited set of enumerated values are permitted, but a value was encountered that is not in the allowed set.static classAdfException.ValueTypeMismatchThrown to indicate that a particular value could not be extracted from a field or attribute because it was not of the correct type.
-
Field Summary
Fields Modifier and Type Field Description static StringMARK_PREFIXUsed in exception backtraces to introduce the mark'stypeafter any preceding information about where the mark was found.static StringMARKS_PREFIXUsed in exception backtraces to indicate that the problem occurs within a node'smarksfields rather than elsewhere in the node's information.static StringNODE_PREFIXUsed in exception backtraces to introduce the node'stypeafter any preceding information about where the node was found.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAdfException(String message)protectedAdfException(String message, Throwable cause)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AdfExceptionbacktrace(String frame)Adds the givenframeto the backtrace for this exception.static <T> Tframe(String frame, Supplier<T> supplier)Wraps code that calculates a value with a catch block that will add the specifiedframeto thebacktrace(String)if that code throws a runtime exception.StringgetPath()Returns the current path information for this exception, if it is available.StringtoString()-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
Field Detail
-
NODE_PREFIX
public static final String NODE_PREFIX
Used in exception backtraces to introduce the node'stypeafter any preceding information about where the node was found.Example:
doc[0].paragraph[0].text:marks[1].code
The periods (.) beforeparagraphandtextare node prefixes.- See Also:
- Constant Field Values
-
MARK_PREFIX
public static final String MARK_PREFIX
Used in exception backtraces to introduce the mark'stypeafter any preceding information about where the mark was found.Example:
doc[0].paragraph[0].text:marks[1].code
The period (.) beforecodeis a mark prefix.- See Also:
- Constant Field Values
-
MARKS_PREFIX
public static final String MARKS_PREFIX
Used in exception backtraces to indicate that the problem occurs within a node'smarksfields rather than elsewhere in the node's information.Example:
doc[0].paragraph[0].text:marks[1].code
The:marksportion indicates that thetextnode's marks were at fault, and specifically the one at index[1], meaning the second mark.- See Also:
- Constant Field Values
-
-
Method Detail
-
frame
public static <T> T frame(String frame, Supplier<T> supplier)
Wraps code that calculates a value with a catch block that will add the specifiedframeto thebacktrace(String)if that code throws a runtime exception.- Type Parameters:
T- the inferred return type of thesupplier- Parameters:
frame- the frame information to be added to the backtrace if an exception is thrownsupplier- the code that generates the requested value- Returns:
- the supplied value
- Throws:
AdfException- withframeadded to the backtrace if anyRuntimeExceptionis thrown by thesupplier
-
backtrace
public final AdfException backtrace(String frame)
Adds the givenframeto the backtrace for this exception. The backtrace is used to provide thepathwhen rendering anAdfException.- Parameters:
frame- the frame information to add to this exception's backtrace- Returns:
this
-
getPath
@Nullable public String getPath()
Returns the current path information for this exception, if it is available. The path is formed by concatenating all of theframevalues that were provided byframe(String, Supplier)orbacktrace(String)calls, in reverse order.- Returns:
- the path information for this exception, or
nullif none has been provided
-
-