[Canonical page](<https://docs.dhtmlx.com/planning-engine/net/api/core/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. It derives from [`PlenException`](<https://docs.dhtmlx.com/planning-engine/net/api/core/errors/plen-exception.md>), so `catch (PlenException)` also catches it. The engine creates it. You rarely construct one yourself.

## Declaration

```csharp
namespace Plen;

public sealed class InputException : PlenException
{
    public InputException(InputErrorKind kind, string message, string? path = null);
    public static InputException Validation(string path, string message);
    public InputErrorKind Kind { get; }
    public string? Path { get; }
}
```

## Constructors

### InputException

```csharp
public InputException(InputErrorKind kind, string message, string? path = null)
```

Creates an input error.

| Name | Type | Description |
|---|---|---|
| `kind` | [`InputErrorKind`](<https://docs.dhtmlx.com/planning-engine/net/api/core/errors/input-exception.md#inputerrorkind>) | `Parse` or `Validation`. |
| `message` | `string` | The error description, stored in `Message`. |
| `path` | `string?` | The input field the error refers to, such as `tasks[2].duration`. Optional; default `null`. |

## Properties

### Kind

```csharp
public InputErrorKind Kind { get; }
```

Whether the input couldn't be decoded (`Parse`) or decoded but is invalid (`Validation`). Calls in the [`Plen.Core`](<https://docs.dhtmlx.com/planning-engine/net/api/core/overview.md>) and [`Plen.Assign`](<https://docs.dhtmlx.com/planning-engine/net/api/assign/overview.md>) packages throw only `Validation`.

### Path

```csharp
public string? Path { get; }
```

The field the error refers to, in its JSON (wire) spelling with snake_case names and zero-based indexes: `tasks[0].constraint_date`, `calendars[1].worktime.days`, `slots[2].value`. It's `null` when the error concerns the whole input or state rather than one field, such as [`SuggestAssignments`](<https://docs.dhtmlx.com/planning-engine/net/api/project-suggest-assignments.md>) on a cyclic project.

### Message

```csharp
public virtual string Message { get; }
```

Inherited from `Exception`. The description only, such as `invalid duration` or `duplicate task id`, without the path or kind. Read `Path` as well when you show the error to a user.

## Static methods

### Validation

```csharp
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/net/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/net/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/net/api/project-analyze.md>) | The supplied data is invalid. |
| [`Project.Level`](<https://docs.dhtmlx.com/planning-engine/net/api/project-level.md>) | The scope names an unknown resource or task, or the config schedules from the end. |
| [`Project.LoadProfile`](<https://docs.dhtmlx.com/planning-engine/net/api/project-load-profile.md>) | The range is empty or has too many buckets, or a resource is unknown. |
| [`Project.Evaluate`](<https://docs.dhtmlx.com/planning-engine/net/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/net/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/net/api/engine-schedule.md>) | The data is invalid. |
| [`SkillLayer.Slots`](<https://docs.dhtmlx.com/planning-engine/net/api/skill-layer-slots.md>) | The resource pool or a requirement is invalid. |

[`Project.Apply`](<https://docs.dhtmlx.com/planning-engine/net/api/project-apply.md>) doesn't throw it: rejected operations come back in [`ApplyReport.Rejected`](<https://docs.dhtmlx.com/planning-engine/net/api/core/changes/rejected-operation.md>). The validation rules for project data are on [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/net/api/core/data/project-data.md>). The [`Validation`](<https://docs.dhtmlx.com/planning-engine/net/api/core/project/validation.md>) mode decides whether fixable input is rejected or repaired.

## InputErrorKind

The kind of an `InputException`.

```csharp
namespace Plen;

public enum InputErrorKind
{
    Parse,
    Validation,
}
```

| Value | Description |
|---|---|
| `Parse` | The input couldn't be decoded. Only the JSON decoders of the separate `Plen.Wire` package produce it. |
| `Validation` | The input decoded but is invalid. Every call in this package produces this kind. |

## Example

```csharp
using Plen;

var monday = Moment.FromYmdHm(2026, 3, 2, 8, 0) ?? throw new InvalidOperationException("invalid date");

var data = new ProjectData
{
    Tasks =
    [
        new TaskData("ok") { StartDate = monday, Duration = 1 },
        new TaskData("broken") { Duration = 2 }, // only one of start, end and duration
    ],
};

try
{
    Engine.Schedule(data, new SolveOptions());
}
catch (InputException e) when (e.Kind == InputErrorKind.Validation)
{
    Console.WriteLine($"{e.Path ?? "(input)"}: {e.Message}");
}
```

## Related

- [`PlenException`](<https://docs.dhtmlx.com/planning-engine/net/api/core/errors/plen-exception.md>) - the base class to catch every engine failure
- [`ProjectException`](<https://docs.dhtmlx.com/planning-engine/net/api/core/errors/project-exception.md>) - the other engine exception, for calls that don't fit the project's state
- [`Validation`](<https://docs.dhtmlx.com/planning-engine/net/api/core/project/validation.md>) - whether fixable input is rejected or repaired
- [Error handling](<https://docs.dhtmlx.com/planning-engine/net/error-handling.md>) - catching, reporting and recovering from engine errors
- [Accept messy input](<https://docs.dhtmlx.com/planning-engine/net/how-to/accept-messy-input.md>) - repairing input instead of throwing
