PlenException#
Abstract base of every exception the engine throws: InputException for invalid input, and ProjectException for a call that doesn't fit the project's state. You never create one directly. Catch it to handle any engine failure in one place.
Declaration#
namespace Plen;
public abstract class PlenException : Exception
The constructor is private protected, so InputException and ProjectException are the only subclasses. Both are sealed.
Properties#
Message#
public override string Message { get; }
Inherited from Exception. The text depends on the subclass: the validation message for InputException, the kebab-case error code for ProjectException.
Subclasses#
| Subclass | When it occurs |
|---|---|
InputException |
The input is invalid. Kind and Path say what failed and where. |
ProjectException |
The call doesn't fit the project's state. Code names the state. |
Each operation page lists which of the two it throws. Framework exceptions (ArgumentNullException for a null argument, and others) don't derive from PlenException. Conflicts, cycles, failure to converge and rejected Apply operations are reported in results, not thrown. See Error handling.
Example#
using Plen;
var data = new ProjectData
{
// A task needs at least two of StartDate, EndDate and Duration.
Tasks = [new TaskData("design") { Duration = 2.0 }],
};
var project = new Project();
try
{
project.Solve(data, new SolveOptions());
}
catch (PlenException ex)
{
switch (ex)
{
case InputException input:
Console.WriteLine($"Invalid input at {input.Path}: {input.Message}");
break;
case ProjectException state:
Console.WriteLine($"Project state: {state.Code}");
break;
}
}
Related#
InputException- thrown for invalid inputProjectException- thrown when a call doesn't fit the project's state- Error handling - how failures surface and how to recover