{"record":{"id":"675dc781b19c41af","repo":"elsa-workflows/elsa-core","slug":"fault-code","errorCode":"{fault.Code}","errorMessage":"{fault.Message}","messagePattern":"\\{fault\\.Message\\}","errorType":"exception","errorClass":"BpmnScopeFaultException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Bpmn/Hosting/BpmnScopeHost.cs","lineNumber":217,"sourceCode":"            memory.SaveState();\n\n            await ApplyAsync(memory, evaluation);\n        });\n\n    private async ValueTask ApplyAsync(BpmnScopeMemory memory, BpmnEvaluation evaluation)\n    {\n        await new BpmnCommandApplier(_context, _process, memory).ApplyAsync(evaluation.Commands);\n\n        switch (evaluation.Continuation)\n        {\n            case BpmnContinuation.Complete complete:\n                // The scope completes because the interpreter said so, never because it ran out of children.\n                await _context.CompleteActivityAsync(new Outcomes(complete.Outcome));\n                break;\n            case BpmnContinuation.Defer:\n                break;\n            case BpmnContinuation.Fault fault:\n                throw new BpmnScopeFaultException(fault.Code, fault.Message);\n            default:\n                throw new NotSupportedException($\"The BPMN continuation '{evaluation.Continuation.GetType().Name}' is not supported by this host.\");\n        }\n    }\n\n    /// <summary>\n    /// Projects every diagnostic the interpreter has appended since the last evaluation onto this scope's own\n    /// execution log, keyed by element id. Under Option A only bound work has an activity id, so a gateway, an\n    /// intermediate event or a sequence flow has nothing else in the journal to say where a token went; this is\n    /// write-only and never read back by the interpreter or this host.\n    /// </summary>\n    /// <remarks>\n    /// Runs on <see cref=\"_context\"/> — this scope's own context — and never a child's: the diagnostic describes\n    /// this scope's decision about a child, and the child may already be torn down by the time this runs. Called\n    /// with the evaluation's own <see cref=\"BpmnEvaluation.State\"/>, before <c>Prune()</c> caps\n    /// <see cref=\"BpmnExecutionState.Diagnostics\"/> at 200 entries, because projecting from what was actually\n    /// persisted would lose whatever pruning already dropped. The last diagnostic id it has projected is kept in\n    /// <see cref=\"BpmnScopeMemory.DiagnosticsCursorPropertyKey\"/> so a resumed scope does not re-emit one a","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Bpmn/Hosting/BpmnScopeHost.cs#L199-L235","documentation":"BpmnScopeHost.ApplyAsync evaluates the interpreter's continuation; a BpmnContinuation.Fault result is surfaced by throwing BpmnScopeFaultException carrying the interpreter-provided fault Code and Message. This is the host's way of propagating a genuine BPMN execution fault (e.g. an error event or expression failure) as a domain exception.","triggerScenarios":"A workflow evaluation in the BPMN scope host returns a Fault continuation — e.g. a BPMN error event fired, an expression evaluation fault, or an interpreter-detected model violation — during EvaluateAsync/ApplyAsync.","commonSituations":"End-signaling an error boundary event; a service task failing with a mapped BPMN error; gateway condition expressions throwing.","solutions":["Read fault.Code and fault.Message to identify which BPMN element/error signaled the fault.","Handle the BPMN error in the model (add an error boundary event / error handler) if it is expected behavior.","If unexpected, inspect diagnostics/logs for the failing element and fix its expression or configuration."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await host.EvaluateAsync(...); }\ncatch (BpmnScopeFaultException ex) { log.LogWarning(\"BPMN fault {Code}: {Message}\", ex.Code, ex.Message); /* route to error handler / boundary event */ }","preventionTips":["Model error boundary events for expected BPMN errors.","Validate gateway/task expressions before deployment.","Monitor fault codes to distinguish model bugs from expected error events."],"tags":["bpmn","fault","workflow"],"backgroundTag":"invalid-state-transition","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}