ProjectException#
Thrown when a call doesn't fit the current state of a Project: the project has no solved baseline, a baseline token is out of date, or an earlier Apply rejected operations. Code says which.
Declaration#
namespace Plen;
public sealed class ProjectException : PlenException
Derives from PlenException, so catch (PlenException) also catches it.
Constructors#
ProjectException(ProjectError)#
public ProjectException(ProjectError code)
Creates the exception with the given code. Message is set to the code's kebab-case spelling.
Parameters
| Name | Type | Description |
|---|---|---|
code |
ProjectError |
The error code |
Properties#
Code#
public ProjectError Code { get; }
The error code. Branch on it to pick the recovery.
Message#
public virtual string Message { get; }
Inherited from Exception. The kebab-case code: "no-baseline", "stale-baseline" or "needs-resync".
ProjectError#
The code of a ProjectException.
namespace Plen;
public enum ProjectError
{
NoBaseline,
StaleBaseline,
NeedsResync,
}
| Variant | Message |
When it occurs | Thrown by |
|---|---|---|---|
NoBaseline |
no-baseline |
The project has no solved baseline: it was never solved, or it has unsolved edits after Apply |
Preview, LoadProfile, Evaluate, SuggestAssignments, Roster, SkillLayer.Slots |
StaleBaseline |
stale-baseline |
A BaselineId in the options or in SchedulingChanges doesn't name the current baseline. A null BaselineId is never checked |
Preview, Apply, LoadProfile, Evaluate, SuggestAssignments |
NeedsResync |
needs-resync |
An earlier Apply rejected an operation, and no full Solve(data, …) has followed. Only a Solve with non-null data clears it |
Solve with null data, Apply, Level |
For how to recover from each code, see Error handling.
Example#
using Plen;
var project = new Project();
var changes = new SchedulingChanges();
try
{
project.Preview(changes, new PreviewOptions());
}
catch (ProjectException e) when (e.Code == ProjectError.NoBaseline)
{
Console.WriteLine(e.Message); // no-baseline
}
Related#
PlenException- the base class to catch every engine failureInputException- the other engine exception, for invalid inputProject- the stateful project whose calls throw it- Error handling - recovering from each code
- Recover from rejected changes - clearing
NeedsResyncafter a rejectedApply