Repository navigation
Partie Results
Handlers return Result<T> to report a value or an expected failure. Providers and Parties return the same result type so they can stop an operation early or inspect its outcome.
Values and failure payloads convert to Result<T>:
Result<CourseSearchResult> found = new CourseSearchResult(42, "Introduction to Biology");
Result<CourseSearchResult> missing = new NotFound("Course not found.");
Result<CourseSearchResult> unavailable = new Conflict("Registration is closed.");
Result<Unit> completed = Unit.Default;Use these same values in an asynchronous handler's return statements. NotFound, Conflict, Forbidden, GatewayError, TimeoutResult, and Error represent failure cases. Exceptions and cancellation propagate separately through the pipeline.
Use Error when a failure needs ProblemDetails-shaped fields and an explicit status:
Result<CourseSearchResult> invalid = new Error(
Title: "Invalid academic year",
Status: 400,
Detail: "The academic year must use the format 2026-2027."
);Error also supports Type, Instance, Extensions, and ErrorDetails. Each ErrorDetail identifies a field through a JSON Pointer.
Deprecated<T> carries a usable value, a UTC deprecation date, and a message:
Result<CourseSearchResult> result = new Deprecated<CourseSearchResult>(
new CourseSearchResult(42, "Introduction to Biology"),
new DateTime(2026, 9, 1, 0, 0, 0, DateTimeKind.Utc),
"Use the v2 course endpoint."
);Deprecated command results commit their unit of work. The consuming framework decides how to present deprecation metadata.
Use a case probe when a Partie needs to inspect the outcome:
if (result.IsNotFound(out var missing))
{
Console.WriteLine(missing.Message);
}IsSuccess and IsDeprecated are separate probes. A deprecated value is usable, but IsSuccess is false for that case.
Use Map to transform successful values while carrying failures through:
Result<string> title = result.Map(course => course.Title);Map preserves deprecation metadata. Use FlatMap when the callback already returns a Result<TOut>. MapAsync and FlatMapAsync accept asynchronous callbacks. These helpers let application code compose results before returning them to Partie.
See Parties for inspecting downstream outcomes and Unit of work for transaction decisions.
- Home
- Getting started
-
Package guides
- Partie
- Expo
-
Mise
- Database setup
- Table mappings
- Aliases
- Relationships
- Result rows
- SQL interpolation
- Queries
- Filtering
- Joins
- Aggregation
- Paging and ordering
- Subqueries
- Set operations
- Common table expressions
- Readers
- Streaming
- Writers
- Inserts
- Updates
- Deletes
- Returned rows
- Custom SQL and procedures
- Transactions
- Resource lifetimes
- Database dialects
- Diagnostics
- Integrations
- Recipes
- Reference
- Troubleshooting
- Development