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#

package org.dhtmlx.plen;

public class InputException extends PlenException {
  public InputException(InputErrorKind kind, String message, String path)
  public InputException(InputErrorKind kind, String message)
  public static InputException validation(String path, String message)

  public InputErrorKind kind;
  public String path;

  public InputException withKind(InputErrorKind value)
  public InputException withPath(String value)
}

Constructors#

InputException#

public InputException(InputErrorKind kind, String message, String path)
public InputException(InputErrorKind kind, String message)

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 getMessage()

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 withKind(InputErrorKind value)

Sets kind and returns this exception.

withPath#

public InputException withPath(String value)

Sets path and returns this exception.

Static methods#

validation#

public static InputException validation(String path, String message)

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.

package org.dhtmlx.plen;

public enum InputErrorKind {
  PARSE,
  VALIDATION
}
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#

import java.util.List;
import org.dhtmlx.plen.*;

public class InputErrorExample {
  public static void main(String[] args) throws Exception {
    Moment monday = Moment.fromYmdHm(2026, 3, 2, 8, 0);

    ProjectData data = new ProjectData()
        .withTasks(List.of(
            new TaskData(Id.str("ok")).withStartDate(monday).withDuration(1.0),
            // only one of start, end and duration
            new TaskData(Id.str("broken")).withDuration(2.0)));

    try {
      Engine.schedule(data, new SolveOptions());
    } catch (InputException e) {
      if (e.kind == InputErrorKind.VALIDATION) {
        String where = e.path != null ? e.path : "(input)";
        System.out.println(where + ": " + e.getMessage());
      }
    }
  }
}