JsonProjectException#
Thrown by new JsonProject(optionsJson) when the options JSON can't be decoded or holds an invalid value. The constructor is the only JsonProject member that throws for bad input: the operations return an error envelope instead. JsonProjectException is unchecked and extends RuntimeException, not PlenException, so catch (PlenException e) doesn't catch it.
Declaration#
;
Constructors#
JsonProjectException#
public
Wraps an engine error. The message is the error envelope built by Wire.errorText(error), and error becomes the cause.
| Name | Type | Description |
|---|---|---|
error |
PlenException |
The error to wrap. |
Methods#
getErrorJson#
public String
Returns the error envelope as JSON text, the same shape the JsonProject operations return on failure:
kind is parse for malformed JSON or a value of the wrong JSON type, and validation for a value that decoded but isn't accepted, such as an unknown validation mode. getMessage() returns the same text.
getError#
public PlenException
Returns the wrapped error, also available as getCause(). For options JSON it's an InputException; read its kind and path for typed handling.
Thrown by#
| Call | When |
|---|---|
new JsonProject(String optionsJson) |
The options JSON is malformed, is null as a JSON document (the text "null"), or holds an invalid ProjectOptions value. |
A Java null passed as optionsJson throws NullPointerException, not JsonProjectException. Wire.newProject decodes the same options and throws the unwrapped InputException.
Example#
;
Output:
{"error":{"code":null,"kind":"validation","message":"unknown validation","path":null},"ok":false}
VALIDATION: unknown validation
Related#
JsonProject- the constructor that throws itInputException- the wrapped errorWire- builds the error envelope it carries- Error handling - errors in the JSON API