Class JsonMappingException

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    UnrecognizedPropertyException

    public class JsonMappingException
    extends JsonProcessingException
    Checked exception used to signal fatal problems with mapping of content.

    One additional feature is the ability to denote relevant path of references (during serialization/deserialization) to help in troubleshooting.

    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  JsonMappingException.Reference
      Simple bean class used to contain references.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void _appendPathDesc​(java.lang.StringBuilder sb)  
      static JsonMappingException from​(JsonParser jp, java.lang.String msg)  
      static JsonMappingException from​(JsonParser jp, java.lang.String msg, java.lang.Throwable problem)  
      java.lang.String getMessage()
      Method is overridden so that we can properly inject description of problem path, if such is defined.
      java.util.List<JsonMappingException.Reference> getPath()  
      void prependPath​(java.lang.Object referrer, int index)
      Method called to prepend a reference information in front of current path
      void prependPath​(java.lang.Object referrer, java.lang.String fieldName)
      Method called to prepend a reference information in front of current path
      void prependPath​(JsonMappingException.Reference r)  
      java.lang.String toString()  
      static JsonMappingException wrapWithPath​(java.lang.Throwable src, java.lang.Object refFrom, int index)
      Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.
      static JsonMappingException wrapWithPath​(java.lang.Throwable src, java.lang.Object refFrom, java.lang.String refFieldName)
      Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.
      static JsonMappingException wrapWithPath​(java.lang.Throwable src, JsonMappingException.Reference ref)
      Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.
      • Methods inherited from class java.lang.Throwable

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

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

      • _path

        protected java.util.LinkedList<JsonMappingException.Reference> _path
        Path through which problem that triggering throwing of this exception was reached.
    • Constructor Detail

      • JsonMappingException

        public JsonMappingException​(java.lang.String msg)
      • JsonMappingException

        public JsonMappingException​(java.lang.String msg,
                                    java.lang.Throwable rootCause)
      • JsonMappingException

        public JsonMappingException​(java.lang.String msg,
                                    JsonLocation loc)
      • JsonMappingException

        public JsonMappingException​(java.lang.String msg,
                                    JsonLocation loc,
                                    java.lang.Throwable rootCause)
    • Method Detail

      • wrapWithPath

        public static JsonMappingException wrapWithPath​(java.lang.Throwable src,
                                                        java.lang.Object refFrom,
                                                        java.lang.String refFieldName)
        Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information. This version of method is called when the reference is through a non-indexed object, such as a Map or POJO/bean.
      • wrapWithPath

        public static JsonMappingException wrapWithPath​(java.lang.Throwable src,
                                                        java.lang.Object refFrom,
                                                        int index)
        Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information. This version of method is called when the reference is through an index, which happens with arrays and Collections.
      • wrapWithPath

        public static JsonMappingException wrapWithPath​(java.lang.Throwable src,
                                                        JsonMappingException.Reference ref)
        Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.
      • prependPath

        public void prependPath​(java.lang.Object referrer,
                                java.lang.String fieldName)
        Method called to prepend a reference information in front of current path
      • prependPath

        public void prependPath​(java.lang.Object referrer,
                                int index)
        Method called to prepend a reference information in front of current path
      • getMessage

        public java.lang.String getMessage()
        Method is overridden so that we can properly inject description of problem path, if such is defined.
        Overrides:
        getMessage in class JsonProcessingException
      • _appendPathDesc

        protected void _appendPathDesc​(java.lang.StringBuilder sb)