Tatu Saloranta | 68bb83d | 2013-04-19 10:41:15 -0700 | [diff] [blame] | 1 | /* Jackson JSON-processor. |
| 2 | * |
| 3 | * Copyright (c) 2007- Tatu Saloranta, tatu.saloranta@iki.fi |
| 4 | */ |
| 5 | |
Tatu Saloranta | f15531c | 2011-12-22 23:00:40 -0800 | [diff] [blame] | 6 | package 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 | */ |
| 13 | public class JsonGenerationException |
| 14 | extends JsonProcessingException |
| 15 | { |
| 16 | private final static long serialVersionUID = 123; // Stupid eclipse... |
Tatu Saloranta | 77be53c | 2015-08-17 22:52:56 -0700 | [diff] [blame] | 17 | |
Tatu Saloranta | e3292f5 | 2016-04-14 19:16:45 -0700 | [diff] [blame] | 18 | // transient since 2.7.4 |
| 19 | protected transient JsonGenerator _processor; |
Tatu Saloranta | 77be53c | 2015-08-17 22:52:56 -0700 | [diff] [blame] | 20 | |
Tatu Saloranta | d302ae0 | 2015-12-27 21:53:15 -0800 | [diff] [blame] | 21 | @Deprecated // since 2.7 |
Tatu Saloranta | 77be53c | 2015-08-17 22:52:56 -0700 | [diff] [blame] | 22 | public JsonGenerationException(Throwable rootCause) { |
Tatu Saloranta | f15531c | 2011-12-22 23:00:40 -0800 | [diff] [blame] | 23 | super(rootCause); |
| 24 | } |
| 25 | |
Tatu Saloranta | d302ae0 | 2015-12-27 21:53:15 -0800 | [diff] [blame] | 26 | @Deprecated // since 2.7 |
Tatu Saloranta | 77be53c | 2015-08-17 22:52:56 -0700 | [diff] [blame] | 27 | public JsonGenerationException(String msg) { |
Tatu Saloranta | f15531c | 2011-12-22 23:00:40 -0800 | [diff] [blame] | 28 | super(msg, (JsonLocation)null); |
| 29 | } |
| 30 | |
Tatu Saloranta | d302ae0 | 2015-12-27 21:53:15 -0800 | [diff] [blame] | 31 | @Deprecated // since 2.7 |
Tatu Saloranta | 77be53c | 2015-08-17 22:52:56 -0700 | [diff] [blame] | 32 | public JsonGenerationException(String msg, Throwable rootCause) { |
Gonçalo Silva | 2bba5dd | 2014-01-25 17:06:21 +0000 | [diff] [blame] | 33 | super(msg, null, rootCause); |
Tatu Saloranta | f15531c | 2011-12-22 23:00:40 -0800 | [diff] [blame] | 34 | } |
Tatu Saloranta | 77be53c | 2015-08-17 22:52:56 -0700 | [diff] [blame] | 35 | |
| 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 Saloranta | f15531c | 2011-12-22 23:00:40 -0800 | [diff] [blame] | 73 | } |