Path: redb/redb.Templates/templates/redb-worker/RedbWorker.Module/Routes/ExceptionRouteBuilder.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Templates/templates/redb-worker/RedbWorker.Module/Routes/ExceptionRouteBuilder.cs ---- using Microsoft.Extensions.Logging; using redb.Route.Core; using redb.Route.Validation; using RedbWorker.Module.Xml; namespace RedbWorker.Module.Routes; /// /// Exception handlers for the whole context: an OnException declared in any route builder wraps /// every route of the module. /// /// Only for a failure whose right outcome is "take the file and answer it". A handled exception is a /// success for the file consumer, so the file moves to the archive. A catch-all /// OnException<Exception>().Handled(true) would be wrong here: it would archive a file the /// database never saw. /// /// public sealed class ExceptionRouteBuilder : RouteBuilder { protected override void Configure() { OnException() .Handled(true) .Process(e => e.In.Body = new OrderReceiptXml { Status = ReceiptStatuses.Rejected, Reason = e.Exception?.Message ?? "The file does not match the order schema.", }) .Log("${header.worker.fileName}: rejected, the file does not match the order schema", LogLevel.Warning) .To(RouteUris.WriteReceipt); } }