[Canonical page](<https://docs.dhtmlx.com/planning-engine/java/api/errors/input-exception/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# 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`](<https://docs.dhtmlx.com/planning-engine/java/api/errors/plen-exception.md>), 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

```java
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

```java
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`](<https://docs.dhtmlx.com/planning-engine/java/api/errors/input-exception.md#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

```java
public InputErrorKind kind
```

`PARSE` when the input couldn't be decoded, `VALIDATION` when it decoded but is invalid. See [`InputErrorKind`](<https://docs.dhtmlx.com/planning-engine/java/api/errors/input-exception.md#inputerrorkind>) for which calls produce each.

### path

```java
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`](<https://docs.dhtmlx.com/planning-engine/java/api/project-suggest-assignments.md>) on a cyclic project.

## Methods

### getMessage

```java
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

```java
public InputException withKind(InputErrorKind value)
```

Sets `kind` and returns this exception.

### withPath

```java
public InputException withPath(String value)
```

Sets `path` and returns this exception.

## Static methods

### validation

```java
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`](<https://docs.dhtmlx.com/planning-engine/java/api/project-solve.md>) | The replacement data is invalid. The previous state and its cached result are kept. |
| [`Project#preview`](<https://docs.dhtmlx.com/planning-engine/java/api/project-preview.md>) | An operation in the changes is rejected, or the `profile` query is invalid. |
| [`Project#analyze`](<https://docs.dhtmlx.com/planning-engine/java/api/project-analyze.md>) | The supplied data is invalid. |
| [`Project#level`](<https://docs.dhtmlx.com/planning-engine/java/api/project-level.md>) | The scope names an unknown resource or task, or `config.scheduleFromEnd` is `true`. |
| [`Project#loadProfile`](<https://docs.dhtmlx.com/planning-engine/java/api/project-load-profile.md>) | The range is empty or has more than 100 000 buckets per resource, or a resource is unknown. |
| [`Project#evaluate`](<https://docs.dhtmlx.com/planning-engine/java/api/project-evaluate.md>), [`evaluateWith`](<https://docs.dhtmlx.com/planning-engine/java/api/project-evaluate.md#evaluatewith>) | A focus id is unknown, or the `level` options are invalid for the baseline. |
| [`Project#suggestAssignments`](<https://docs.dhtmlx.com/planning-engine/java/api/project-suggest-assignments.md>) | An option or slot is invalid, or the accepted state has a cycle. |
| [`Engine.schedule`](<https://docs.dhtmlx.com/planning-engine/java/api/engine-schedule.md>), `Engine.scheduleState` | The data is invalid. |
| [`Decode.fromJson`](<https://docs.dhtmlx.com/planning-engine/java/api/json/decode.md#fromjson>), `Decode.list` | The JSON is malformed or doesn't match the target type (`PARSE`), or a value check fails (`VALIDATION`). |
| [`Wire.newProject`](<https://docs.dhtmlx.com/planning-engine/java/api/json/wire.md#newproject>) | The options JSON is invalid. |

[`Project#apply`](<https://docs.dhtmlx.com/planning-engine/java/api/project-apply.md>) doesn't throw it: rejected operations come back in [`ApplyReport.rejected`](<https://docs.dhtmlx.com/planning-engine/java/api/changes/apply-report.md#rejected>). [`SkillLayer.slots`](<https://docs.dhtmlx.com/planning-engine/java/api/skill-layer-slots.md>) throws [`MatchException`](<https://docs.dhtmlx.com/planning-engine/java/api/errors/match-exception.md>) instead; `MatchException.Invalid#toPlenException()` converts it to an `InputException` of kind `VALIDATION`. The validation rules for project data are on [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/java/api/data/project-data.md>). The [`Validation`](<https://docs.dhtmlx.com/planning-engine/java/api/project/validation.md>) mode decides whether fixable input is rejected or repaired.

## InputErrorKind

The kind of an `InputException`.

```java
package org.dhtmlx.plen;

public enum InputErrorKind {
  PARSE,
  VALIDATION
}
```

| Value | Description |
|---|---|
| `PARSE` | The input couldn't be decoded. Produced by the JSON API: [`Decode`](<https://docs.dhtmlx.com/planning-engine/java/api/json/decode.md>), [`Wire`](<https://docs.dhtmlx.com/planning-engine/java/api/json/wire.md>) and [`JsonProject`](<https://docs.dhtmlx.com/planning-engine/java/api/json/json-project.md>). |
| `VALIDATION` | The input decoded but is invalid. Every typed engine call produces this kind. |

## Example

```java
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());
      }
    }
  }
}
```

## Related

- [`PlenException`](<https://docs.dhtmlx.com/planning-engine/java/api/errors/plen-exception.md>) - the base class
- [`ProjectException`](<https://docs.dhtmlx.com/planning-engine/java/api/errors/project-exception.md>) - the error for a call that doesn't fit the project state
- [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/java/api/data/project-data.md#validation>) - the validation rules for project data
- [`Validation`](<https://docs.dhtmlx.com/planning-engine/java/api/project/validation.md>) - repair fixable input instead of rejecting it
- [Error handling](<https://docs.dhtmlx.com/planning-engine/java/error-handling.md#input-errors>) - reporting a validation error with its path
