Class JsonStrParseObjException

  • All Implemented Interfaces:
    java.io.Serializable

    public class JsonStrParseObjException
    extends JsonBindingObjException
    JsonStrParseObjException 🠞
    • 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 & transforming JsonString's into Java-Type's

    • Obj - 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 a JsonObject property and a JsonArray index are somewhat different - there are two different exceptions for them! (An Exception for Object's and an exception for Array's).

      This class reports string-parsing errors that occur when retrieving data from JsonObject's

    • Exception - This class inherits class Exception
    Used to indicate that a specific JsonString within a JsonObject or JsonArray 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
    propertyName java.lang.String JsonBindingObjException
    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 of JsonBindingException 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.JsonStrParseObjException: 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 JsonObject: {"yearPurchased":"abc"} Property-Name: yearPurchased 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


    • Constructor Summary

      Constructors 
      Constructor Description
      JsonStrParseObjException​(String message, Throwable cause, JsonObject errorSourceJsonObject, String propertyName, JsonValue valueRetrieved, Class<?> methodReturnJavaType)
      Constructs a JsonStrParseObjException with the specified detail message, cause, and user-provided convenience-field values.
      JsonStrParseObjException​(Throwable cause, JsonObject errorSourceJsonObject, String propertyName, JsonValue valueRetrieved, Class<?> methodReturnJavaType)
      Constructs a JsonStrParseObjException with no specified cause, and the user-provided convenience-field values.
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        🡇     🗕  🗗  🗖
        public static final long serialVersionUID
        This fulfils the SerialVersion UID requirement for all classes that implement Java's interface java.io.Serializable. Using the Serializable 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's java.lang.Exception and java.lang.Error classes implement the Serializable 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 instances of this Exception ought to guarantee that when an instance is thrown - any & all "Convenience Fields" have been properly set.

        If this package is extended, or if this exception is used elsewhere, try to remember to not to accidentally leave this field null when using this class' constructors.

        In Summary:
        All this is really trying to explain is that, when debugging your code, if in the analysis of a particular Exception, that analysis causes another exception throw (NullPointerException) - BECAUSE THIS CONVENIENCE FIELD WAS LEFT NULL - you would likely get pretty angry.

        The String that has caused the exception.
    • Constructor Detail

      • JsonStrParseObjException

        🡅  🡇     🗕  🗗  🗖
        public JsonStrParseObjException​(java.lang.Throwable cause,
                                        JsonObject errorSourceJsonObject,
                                        java.lang.String propertyName,
                                        JsonValue valueRetrieved,
                                        java.lang.Class<?> methodReturnJavaType)
        Constructs a JsonStrParseObjException with no specified cause, and the user-provided convenience-field values.
        Parameters:
        cause - The exception thrown by the user-provided 'parser'
        errorSourceJsonObject - The JsonObject from which the property is being retrieved / extracted.
        propertyName - This is the property-name into the JsonObject from which the property is being retrieved / extracted.
        valueRetrieved - This is the JsonValue that was extracted from the JsonObject 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 be JsonValue.NULL
        methodReturnJavaType - Class ReadJSON will always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.
      • JsonStrParseObjException

        🡅     🗕  🗗  🗖
        public JsonStrParseObjException​(java.lang.String message,
                                        java.lang.Throwable cause,
                                        JsonObject errorSourceJsonObject,
                                        java.lang.String propertyName,
                                        JsonValue valueRetrieved,
                                        java.lang.Class<?> methodReturnJavaType)
        Constructs a JsonStrParseObjException with the specified detail message, cause, and user-provided convenience-field values.
        Parameters:
        message - the detail message.
        cause - The exception thrown by the user-provided 'parser'
        errorSourceJsonObject - The JsonObject from which the property is being retrieved / extracted.
        propertyName - This is the property-name into the JsonObject from which the property is being retrieved / extracted.
        valueRetrieved - This is the JsonValue that was extracted from the JsonObject 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 be JsonValue.NULL
        methodReturnJavaType - Class ReadJSON will always provide the ultimate Java-Type that is to be returned by the method where this exception is being thrown.