Package Torello.Java.Additional
Class JsonStrParseArrException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- javax.json.JsonException
-
- Torello.Java.Additional.JsonBindingException
-
- Torello.Java.Additional.JsonBindingArrException
-
- Torello.Java.Additional.JsonStrParseArrException
-
- All Implemented Interfaces:
java.io.Serializable
public class JsonStrParseArrException extends JsonBindingArrException
JsonStrParseArrException 🠞Json
- This exception is thrown by the Json Reader Classes
StrParse
- This particular class is tailored to hold information about errors that occur while parsing & transformingJsonString's
intoJava-Type's
Arr
- Since these exceptions contain 'convenience fields' which provide some simple data about the Json that caused the exception throw, and since the 'relevant information' about aJsonObject
property and aJsonArray
index are somewhat different - there are two different exceptions for them! (An Exception forObject's
and an exception forArray's
).
This class reports string-parsing errors that occur when retrieving data fromJsonArray's
Exception
- This class inherits classException
Used to indicate that a specificJsonString
within aJsonObject
orJsonArray
was not properly parsed into a target Java-Type.
The following'final'
Convenience Fields are exported by this Exception Class:Inherited Field Field Type Inherited From index
int
JsonBindingArrException
errorSourceJsonStruct
JsonStructure
JsonBindingException
expectedJsonType
JsonValue.ValueType
JsonBindingException
methodReturnJavaType
java.lang.Class
JsonBindingException
valueRetrieved
JsonValue
JsonBindingException
The main benefit of this complicated exception-class inheritance tree are the exception messages generated by this class. If any sub-class ofJsonBindingException
is thrown, it is guaranteed to produce as much detail as possible about which Json-Element has generated the error. Below is an example of what this class exception messages look like:
Terminal Output:
Exception in thread "main" Torello.Java.Additional.JsonStrParseArrException: The User-Provided Parser threw an Exception while attempting to parse / transform a Json-String Cause-Exception Class: java.lang.NumberFormatException Cause-Exception Message: For input string: "abc" Found In JsonArray: [null,"3","abc"] At Index: 2 Expected Json-Type: JsonValue.ValueType.STRING Contained JsonValue: "abc" Having Actual Json-Type: JsonValue.ValueType.STRING Converting To Java-Type: java.lang.Integer ... [followed by stack-trace]- See Also:
- Serialized Form
Hi-Lited Source-Code:- View Here: Torello/Java/Additional/JsonStrParseArrException.java
- Open New Browser-Tab: Torello/Java/Additional/JsonStrParseArrException.java
-
-
Field Summary
Serializable ID Modifier and Type Field static long
serialVersionUID
'final'
Exception Convenience FieldsModifier and Type Field String
s
-
Fields inherited from class Torello.Java.Additional.JsonBindingArrException
index
-
Fields inherited from class Torello.Java.Additional.JsonBindingException
errorSourceJsonStruct, expectedJsonType, methodReturnJavaType, valueRetrieved
-
-
Constructor Summary
Constructors Constructor JsonStrParseArrException(String message, Throwable cause, JsonArray errorSourceJsonArray, int index, JsonValue valueRetrieved, Class<?> methodReturnJavaType)
JsonStrParseArrException(Throwable cause, JsonArray errorSourceJsonArray, int index, JsonValue valueRetrieved, Class<?> methodReturnJavaType)
-
Method Summary
-
Methods inherited from class Torello.Java.Additional.JsonBindingArrException
BASE_MESSAGE_ARR
-
Methods inherited from class Torello.Java.Additional.JsonBindingException
BASE_MESSAGE
-
-
-
-
Field Detail
-
serialVersionUID
public static final long serialVersionUID
This fulfils the SerialVersion UID requirement for all classes that implement Java'sinterface java.io.Serializable
. Using theSerializable
Implementation offered by java is very easy, and can make saving program state when debugging a lot easier. It can also be used in place of more complicated systems like "hibernate" to store data as well.
Note that Java'sjava.lang.Exception
andjava.lang.Error
classes implement theSerializable interface
, and a warning-free build expects this field be defined here.- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final long serialVersionUID = 1;
-
s
public final java.lang.String s
This field is provided to the user as a matter of convenience. All instantiations of thisException
are should guarantee to enforce and ensure that when an instance of this exception is thrown, the convenience field is not set null. If this package is extended, it is up to the programmer/user to make sure not to leave this field null when using one of these constructors.
IMPORTANT: All this is really trying to explain is that, when debugging your code, if in the analysis of a particularException
, that analysis causes another exception throw (NullPointerException
) - BECAUSE THIS CONVENIENCE FIELD WAS LEFT NULL - would be an unnecessary source of headache.
TheString
that couldn't be properly parsed, and has caused this exception throw.- Code:
- Exact Field Declaration Expression:
public final String s;
-
-
Constructor Detail
-
JsonStrParseArrException
public JsonStrParseArrException(java.lang.Throwable cause, JsonArray errorSourceJsonArray, int index, JsonValue valueRetrieved, java.lang.Class<?> methodReturnJavaType)
Constructs aJsonStrParseArrException
with no specified detail messsage, and the user-provided convenience-field values.- Parameters:
cause
- The exception thrown by the user-provided'parser'
errorSourceJsonArray
- TheJsonArray
from which the element is being retrieved / extracted.index
- This is theJsonArray
index from which the element is being retrieved / extracted.valueRetrieved
- This is theJsonValue
that was extracted from theJsonArray
which caused an exception. Note that if the entity did not exist, then this parameter will be Java-Null. If Json-Null was found, then this parameter should beJsonValue.NULL
methodReturnJavaType
- ClassReadJSON
will always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.
-
JsonStrParseArrException
public JsonStrParseArrException(java.lang.String message, java.lang.Throwable cause, JsonArray errorSourceJsonArray, int index, JsonValue valueRetrieved, java.lang.Class<?> methodReturnJavaType)
Constructs aJsonStrParseArrException
with the specified detail message, and user-provided convenience-field values.- Parameters:
message
- the detail message.cause
- The exception thrown by the user-provided'parser'
errorSourceJsonArray
- TheJsonArray
from which the element is being retrieved / extracted.index
- This is theJsonArray
index from which the element is being retrieved / extracted.valueRetrieved
- This is theJsonValue
that was extracted from theJsonArray
which caused an exception. Note that if the entity did not exist, then this parameter will be Java-Null. If Json-Null was found, then this parameter should beJsonValue.NULL
methodReturnJavaType
- ClassReadJSON
will always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.
-
-