Error#
The error returned by every fallible plen-core call, as Result<T, Error>. It's an enum with two variants: invalid input, or a call that doesn't fit the project's current state. You get it from the methods of Project and from schedule.
Declaration#
Error isn't Clone or PartialEq. Match on it with match or matches! instead of comparing with ==.
Variants#
| Variant | When it occurs |
|---|---|
Input(InputError) |
The data or options passed to the call are invalid. The project's state is unchanged. |
Project(ProjectError) |
The call doesn't fit the project's current state, for example a preview on an unsolved project. The project's state is unchanged. |
Conflicts, cycles, failure to converge and rejected apply operations aren't errors. They're reported inside the call's result.
Which calls return each variant#
| Call | Error::Input |
Error::Project |
|---|---|---|
Project::solve |
yes | yes |
Project::preview |
yes | yes |
Project::analyze |
yes | no |
Project::apply |
no | yes |
Project::level |
yes | yes |
Project::load_profile |
yes | yes |
Project::evaluate, Project::evaluate_with |
yes | yes |
Project::suggest_assignments |
yes | yes |
Project::roster |
no | yes |
schedule |
yes | no |
Each method in Project lists the exact conditions.
Display#
Both variants are transparent. Display prints the inner error's text:
Error::Input: themessageof theInputError, without itspathError::Project: the variant's name in kebab-case:no-baseline,stale-baselineorneeds-resync
Conversions#
| Impl | Result |
|---|---|
From<InputError> |
Error::Input |
From<ProjectError> |
Error::Project |
From<MatchError> |
MatchError::Invalid { path, message } becomes Error::Input with kind Validation and that path and message. MatchError::Project(e) becomes Error::Project(e). Defined in plen-assign. |
With these impls, ? turns an InputError, ProjectError or MatchError into Error in a function that returns Result<_, Error>. Since Error implements std::error::Error, ? also turns it into Box<dyn std::error::Error>.
Example#
use ;
For recovery patterns for each variant, see Error handling.
Related#
ApplyReport- where rejectedapplyoperations are reported insteadScheduleResult- where conflicts, cycles and non-convergence are reported instead- Scheduling a Project - shows
?on solve calls that return this error - Accept messy input - shows how to repair data instead of getting
Error::Input