{"record":{"id":"86e0c9ca7db32f93","repo":"elsa-workflows/elsa-core","slug":"faultexception-raised-by-fault-activity","errorCode":null,"errorMessage":"FaultException raised by Fault activity","messagePattern":"FaultException raised by Fault activity","errorType":"exception","errorClass":"FaultException","httpStatus":null,"severity":"warning","filePath":"src/modules/Elsa.Workflows.Core/Activities/Fault.cs","lineNumber":71,"sourceCode":"        DisplayName = \"Type\",\n        Description = \"The type of fault. Examples: System, Business, Integration, etc.\"\n        )]\n    public Input<string> FaultType { get; set; } = null!;\n\n    /// <summary>\n    /// The message to include with the fault.\n    /// </summary>\n    [Input(Description = \"The message to include with the fault.\")]\n    public Input<string?> Message { get; set; } = null!;\n\n    /// <inheritdoc />\n    protected override void Execute(ActivityExecutionContext context)\n    {\n        var code = Code.GetOrDefault(context) ?? \"0\";\n        var category = Category.GetOrDefault(context) ?? \"General\";\n        var type = FaultType.GetOrDefault(context) ?? \"System\";\n        var message = Message.GetOrDefault(context);\n        throw new FaultException(code, category, type, message);\n    }\n}","sourceCodeStart":53,"sourceCodeEnd":73,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Workflows.Core/Activities/Fault.cs#L53-L73","documentation":"The Fault activity's Execute reads its Code, Category, Type, and Message inputs and throws a FaultException with those values. This is the intended mechanism for deliberately faulting a workflow: the thrown exception is converted into a workflow fault (incident) rather than a bug. The message 'FaultException raised by Fault activity' is the default message when the Message input is not set.","triggerScenarios":"A workflow contains a Fault activity and execution reaches it — either as designed (validation failure, business rule violation) or accidentally due to a miswired condition. When the Message input is left unset, the default message 'FaultException raised by Fault activity' is used.","commonSituations":"Business-rule checks implemented with Fault (e.g. 'order total exceeds limit'); workflows faulting unexpectedly because an If/condition routed into a Fault activity; missing Message input making incidents harder to triage.","solutions":["Set the Fault activity's Message (and Code/Category/Type) inputs to a descriptive value for triage.","If the fault is unintended, inspect the workflow path/conditions that routed execution into the Fault activity and fix the branching.","Handle expected faults downstream via workflow fault/incident handling (compensation, retry, or catch semantics) instead of letting the instance end in fault."],"exampleFix":"// before\nnew Fault { Code = new(\"ERR-409\") } // no message\n// after\nnew Fault { Code = new(\"ERR-409\"), Category = new(\"Business\"), Message = new(\"Order total exceeds credit limit\") }","handlingStrategy":"try-catch","validationCode":"// Pre-check the business rule before the Fault activity can be reached\nif (order.Total > creditLimit)\n    throw new InvalidOperationException($\"Order {order.Id} exceeds credit limit {creditLimit}\");","typeGuard":null,"tryCatchPattern":"try { await runner.RunAsync(workflow); }\ncatch (FaultException ex) when (ex.Category == \"Business\") { /* route to review queue */ }","preventionTips":["Always set a meaningful Message on Fault activities","Review workflow graphs for accidental edges into Fault activities","Define conventions for fault codes/categories so incidents are filterable"],"tags":["workflow","fault","activity"],"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-15T23:17:13.987Z"}