java.lang.Object
org.praxislive.core.Value
org.praxislive.core.types.PError
An error message, possibly wrapping a Java Exception.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.praxislive.core.Value
Value.Type<T extends Value> -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondataMap()The error as aPMap.booleanValues must override the default equals method.The error type, usually the simple name of a Java Exception.The wrapped exception, if available.Deprecated.Cast or convert the provided value into a PError, wrapped in an Optional.inthashCode()Values must override the default hashcode method.message()The error message.static PErrorCreate a PError of the given type and message.static PErrorCreate a PError wrapping the given Exception.static PErrorCreate a PError wrapping the given Exception, with a custom message.static PErrorCreate a PError of the given message.static PErrorParse a String as a PError.A short form of the stack trace leading to this error, if available.toString()Values must override the default method to return a string representation that is immutable.
-
Field Details
-
TYPE_NAME
Value type name.- See Also:
-
-
Method Details
-
exceptionType
Deprecated. -
errorType
The error type, usually the simple name of a Java Exception.- Returns:
- error type
-
message
The error message.- Returns:
- error message
-
stackTrace
A short form of the stack trace leading to this error, if available. Otherwise an empty String.- Returns:
- stack trace or empty String.
-
exception
The wrapped exception, if available. Direct access to the exception is only available in the process in which the error was created.- Returns:
- optional exception
-
toString
Description copied from class:ValueValues must override the default method to return a string representation that is immutable. -
dataMap
The error as aPMap. This is similar toPMap.MapBasedValueexcept that the map representation of a PError is created lazily. A PError recreated from its PMap representation will not have an Exception reference.- Returns:
- PError data as a PMap
-
hashCode
public int hashCode()Description copied from class:ValueValues must override the default hashcode method. -
equals
Description copied from class:ValueValues must override the default equals method. This method should only returntrueif the supplied Object is of the same type as the implementing Value. Values of an unknown type should be coerced before calling this method. This method does not have to guarantee thatthis.equals(that) == this.toString().equals(that.toString()) -
parse
Parse a String as a PError. This first parses the text as a PMap.- Parameters:
string- text representation- Returns:
- PError instance
- Throws:
ValueFormatException- if the text cannot be parsed
-
from
Cast or convert the provided value into a PError, wrapped in an Optional. If the value is already a PError, the Optional will wrap the existing value. If the value is not a PError and cannot be converted into one, an empty Optional is returned.- Parameters:
value- value- Returns:
- optional PError
-
of
Create a PError wrapping the given Exception. The message will be taken from the exception, and the error type will be the simple name of the exception's class.- Parameters:
ex- exception- Returns:
- PError instance
-
of
Create a PError wrapping the given Exception, with a custom message. The exception's message will be ignored. The error type will be the simple name of the exception's class.- Parameters:
ex- exceptionmsg- message- Returns:
- PError instance
-
of
Create a PError of the given message. The error type will beException.- Parameters:
msg- message- Returns:
- PError instance
-
of
Create a PError of the given type and message. The error type will be the simple name of the passed in Exception type.- Parameters:
type- error typemsg- message- Returns:
- PError instance
-