InputException#
Thrown when the data or options passed to a call are invalid. The call leaves the project state as it was. InputException extends PlenException, so catch (PlenException e) also catches it. It's unchecked, and no method declares it in throws. The engine creates it; code rarely constructs one directly.
Declaration#
;
Constructors#
InputException#
public
public
Creates an input error. The two-argument form sets path to null.
| Name | Type | Description |
|---|---|---|
kind |
InputErrorKind |
PARSE or VALIDATION. |
message |
String |
The error description, returned by getMessage(). |
path |
String |
The input field the error refers to, such as tasks[2].duration. Optional; null when omitted. |
Fields#
kind#
public InputErrorKind kind
PARSE when the input couldn't be decoded, VALIDATION when it decoded but is invalid. See InputErrorKind for which calls produce each.
path#
public String path
The field the error refers to, in its JSON (wire) spelling with snake_case names and zero-based indexes: tasks[3].constraint_date, scope.resources, slots[2].value, newResourcePenalty. It's null for parse errors and when the error concerns the whole state rather than one field, such as Project#suggestAssignments on a cyclic project.
Methods#
getMessage#
public String
Inherited from Throwable. Returns the description alone, without the path or kind. Read path as well when showing the error to a user.
withKind#
public InputException
Sets kind and returns this exception.
withPath#
public InputException
Sets path and returns this exception.
Static methods#
validation#
public static InputException
Creates an error with kind set to VALIDATION.
| Name | Type | Description |
|---|---|---|
path |
String |
The field the error refers to. |
message |
String |
The error description. |
Returns the new InputException.
Thrown by#
| Call | When |
|---|---|
Project#solve |
The replacement data is invalid. The previous state and its cached result are kept. |
Project#preview |
An operation in the changes is rejected, or the profile query is invalid. |
Project#analyze |
The supplied data is invalid. |
Project#level |
The scope names an unknown resource or task, or config.scheduleFromEnd is true. |
Project#loadProfile |
The range is empty or has more than 100 000 buckets per resource, or a resource is unknown. |
Project#evaluate, evaluateWith |
A focus id is unknown, or the level options are invalid for the baseline. |
Project#suggestAssignments |
An option or slot is invalid, or the accepted state has a cycle. |
Engine.schedule, Engine.scheduleState |
The data is invalid. |
Decode.fromJson, Decode.list |
The JSON is malformed or doesn't match the target type (PARSE), or a value check fails (VALIDATION). |
Wire.newProject |
The options JSON is invalid. |
Project#apply doesn't throw it: rejected operations come back in ApplyReport.rejected. SkillLayer.slots throws MatchException instead; MatchException.Invalid#toPlenException() converts it to an InputException of kind VALIDATION. The validation rules for project data are on ProjectData. The Validation mode decides whether fixable input is rejected or repaired.
InputErrorKind#
The kind of an InputException.
;
| Value | Description |
|---|---|
PARSE |
The input couldn't be decoded. Produced by the JSON API: Decode, Wire and JsonProject. |
VALIDATION |
The input decoded but is invalid. Every typed engine call produces this kind. |
Example#
;
;
Related#
PlenException- the base classProjectException- the error for a call that doesn't fit the project stateProjectData- the validation rules for project dataValidation- repair fixable input instead of rejecting it- Error handling - reporting a validation error with its path