blob: 59f4ae5dac09af1996207f0e10743f0bb95fd3ba [file] [log] [blame]
Tatu Saloranta68bb83d2013-04-19 10:41:15 -07001/* Jackson JSON-processor.
2 *
3 * Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi
4 */
5
Tatu Salorantaf15531c2011-12-22 23:00:40 -08006package com.fasterxml.jackson.core;
7
8/**
9 * Exception type for exceptions during JSON writing, such as trying
10 * to output content in wrong context (non-matching end-array or end-object,
11 * for example).
12 */
13public class JsonGenerationException
14 extends JsonProcessingException
15{
16 private final static long serialVersionUID = 123; // Stupid eclipse...
Tatu Saloranta77be53c2015-08-17 22:52:56 -070017
Tatu Salorantae3292f52016-04-14 19:16:45 -070018 // transient since 2.7.4
19 protected transient JsonGenerator _processor;
Tatu Saloranta77be53c2015-08-17 22:52:56 -070020
Tatu Salorantad302ae02015-12-27 21:53:15 -080021 @Deprecated // since 2.7
Tatu Saloranta77be53c2015-08-17 22:52:56 -070022 public JsonGenerationException(Throwable rootCause) {
Tatu Salorantaf15531c2011-12-22 23:00:40 -080023 super(rootCause);
24 }
25
Tatu Salorantad302ae02015-12-27 21:53:15 -080026 @Deprecated // since 2.7
Tatu Saloranta77be53c2015-08-17 22:52:56 -070027 public JsonGenerationException(String msg) {
Tatu Salorantaf15531c2011-12-22 23:00:40 -080028 super(msg, (JsonLocation)null);
29 }
30
Tatu Salorantad302ae02015-12-27 21:53:15 -080031 @Deprecated // since 2.7
Tatu Saloranta77be53c2015-08-17 22:52:56 -070032 public JsonGenerationException(String msg, Throwable rootCause) {
Gonçalo Silva2bba5dd2014-01-25 17:06:21 +000033 super(msg, null, rootCause);
Tatu Salorantaf15531c2011-12-22 23:00:40 -080034 }
Tatu Saloranta77be53c2015-08-17 22:52:56 -070035
36 /**
37 * @since 2.7
38 */
39 public JsonGenerationException(Throwable rootCause, JsonGenerator g) {
40 super(rootCause);
41 _processor = g;
42 }
43
44 /**
45 * @since 2.7
46 */
47 public JsonGenerationException(String msg, JsonGenerator g) {
48 super(msg, (JsonLocation) null);
49 _processor = g;
50 }
51
52 /**
53 * @since 2.7
54 */
55 public JsonGenerationException(String msg, Throwable rootCause, JsonGenerator g) {
56 super(msg, null, rootCause);
57 _processor = g;
58 }
59
60 /**
61 * Fluent method that may be used to assign originating {@link JsonGenerator},
62 * to be accessed using {@link #getProcessor()}.
63 *
64 * @since 2.7
65 */
66 public JsonGenerationException withGenerator(JsonGenerator g) {
67 _processor = g;
68 return this;
69 }
70
71 @Override
72 public JsonGenerator getProcessor() { return _processor; }
Tatu Salorantaf15531c2011-12-22 23:00:40 -080073}