|
24 | 24 | import java.io.IOException;
|
25 | 25 | import java.io.InputStream;
|
26 | 26 | import java.net.URL;
|
| 27 | +import java.util.ArrayList; |
| 28 | +import java.util.List; |
27 | 29 |
|
28 | 30 | import static com.jayway.jsonpath.Option.ALWAYS_RETURN_LIST;
|
29 | 31 | import static com.jayway.jsonpath.Option.AS_PATH_LIST;
|
@@ -255,11 +257,24 @@ public <T> T map(Object jsonObject, MapFunction mapFunction, Configuration confi
|
255 | 257 | public <T> T delete(Object jsonObject, Configuration configuration) {
|
256 | 258 | notNull(jsonObject, "json can not be null");
|
257 | 259 | notNull(configuration, "configuration can not be null");
|
258 |
| - EvaluationContext evaluationContext = path.evaluate(jsonObject, jsonObject, configuration, true); |
259 |
| - for (PathRef updateOperation : evaluationContext.updateOperations()) { |
260 |
| - updateOperation.delete(configuration); |
| 260 | + |
| 261 | + boolean optSuppressExceptions = configuration.containsOption(Option.SUPPRESS_EXCEPTIONS); |
| 262 | + |
| 263 | + try { |
| 264 | + EvaluationContext evaluationContext = path.evaluate(jsonObject, jsonObject, configuration, true); |
| 265 | + for (PathRef updateOperation : evaluationContext.updateOperations()) { |
| 266 | + updateOperation.delete(configuration); |
| 267 | + } |
| 268 | + return resultByConfiguration(jsonObject, configuration, evaluationContext); |
| 269 | + } catch (RuntimeException e) { |
| 270 | + if (!optSuppressExceptions) { |
| 271 | + throw e; |
| 272 | + } else { |
| 273 | + List<String> list = new ArrayList<String>(); // the log messages |
| 274 | + list.add("delete throws "+e.getMessage()); // TODO |
| 275 | + return (T) list; |
| 276 | + } |
261 | 277 | }
|
262 |
| - return resultByConfiguration(jsonObject, configuration, evaluationContext); |
263 | 278 | }
|
264 | 279 |
|
265 | 280 | /**
|
|
0 commit comments