• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.databind.exc;
2 
3 import com.fasterxml.jackson.core.JsonParser;
4 
5 import com.fasterxml.jackson.databind.JavaType;
6 import com.fasterxml.jackson.databind.JsonMappingException;
7 
8 /**
9  * Exception type used for generic failures during processing by
10  * {@link com.fasterxml.jackson.databind.deser.ValueInstantiator}:
11  * commonly used to wrap exceptions thrown by constructor or factory
12  * method.
13  *<p>
14  * Note that this type is sibling of {@link MismatchedInputException} and
15  * {@link InvalidDefinitionException} since it is not clear if problem is
16  * with input, or type definition (or possibly neither).
17  * It is recommended that if either specific input, or type definition problem
18  * is known, a more accurate exception is used instead.
19  *
20  * @since 2.10
21  */
22 @SuppressWarnings("serial")
23 public class ValueInstantiationException
24     extends JsonMappingException
25 {
26     protected final JavaType _type;
27 
ValueInstantiationException(JsonParser p, String msg, JavaType type, Throwable cause)28     protected ValueInstantiationException(JsonParser p, String msg,
29             JavaType type, Throwable cause) {
30         super(p, msg, cause);
31         _type = type;
32     }
33 
ValueInstantiationException(JsonParser p, String msg, JavaType type)34     protected ValueInstantiationException(JsonParser p, String msg,
35             JavaType type) {
36         super(p, msg);
37         _type = type;
38     }
39 
from(JsonParser p, String msg, JavaType type)40     public static ValueInstantiationException from(JsonParser p, String msg,
41             JavaType type) {
42         return new ValueInstantiationException(p, msg, type);
43     }
44 
from(JsonParser p, String msg, JavaType type, Throwable cause)45     public static ValueInstantiationException from(JsonParser p, String msg,
46             JavaType type, Throwable cause) {
47         return new ValueInstantiationException(p, msg, type, cause);
48     }
49 
50     /**
51      * Accessor for type fully resolved type that had the problem; this should always
52      * known and available, never <code>null</code>
53      */
getType()54     public JavaType getType() {
55         return _type;
56     }
57 }
58