-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catch the exception and handling the exception in the workflow #5422
Open
fanslead
wants to merge
7
commits into
elsa-workflows:main
Choose a base branch
from
fanslead:feature/catchflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+105
−1
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
488b3e9
feat: catch flow
35bdeb4
Merge branch 'main' into feature/catchflow
fanslead 81c2dcb
feat: catch flow
4340d63
Merge branch 'feature/catchflow' of https://github.com/fanslead/elsa-…
8a5882c
feat: use Cast<Catch>
5e9767b
feat: update CreateActivityExecutionContext to CreateActivityExecutio…
3050f6b
Merge branch 'main' into feature/catchflow
fanslead File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Runtime.CompilerServices; | ||
using Elsa.Workflows.Attributes; | ||
using Elsa.Workflows.Models; | ||
using Elsa.Workflows.UIHints; | ||
|
||
namespace Elsa.Workflows.Activities; | ||
|
||
/// <summary> | ||
/// Catch the Exception. | ||
/// </summary> | ||
[Activity("Elsa", "Primitives", "Catch the Exception.")] | ||
public class Catch : Activity | ||
{ | ||
/// <inheritdoc /> | ||
public Catch([CallerFilePath] string? source = default, [CallerLineNumber] int? line = default) : base(source, line) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// A value indicating whether to catch all exceptions from all activities. | ||
/// </summary> | ||
[Input(Description = "A value indicating whether to catch all exceptions from all activities.")] | ||
public Input<bool> CatchAll { get; set; } = default!; | ||
|
||
/// <summary> | ||
/// The IDs of the activities to catch exceptions from. | ||
/// </summary> | ||
[Input(Description = "The IDs of the activities to catch exceptions from.", | ||
UIHint = InputUIHints.MultiText)] | ||
public Input<ICollection<string>?> CatchActivities { get; set; } = default!; | ||
|
||
/// <inheritdoc /> | ||
protected override ValueTask ExecuteAsync(ActivityExecutionContext context) | ||
{ | ||
return context.CompleteActivityAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/modules/Elsa.Workflows.Core/Signals/ExceptionSignal.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,10 @@ | ||||||
using Elsa.Workflows.Contracts; | ||||||
|
||||||
namespace Elsa.Workflows.Signals; | ||||||
|
||||||
/// <summary> | ||||||
/// /// Sent by ExceptionHandlingMiddleware to notify their composite container that it has exception. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
/// </summary> | ||||||
/// <param name="Activity">The exception activity</param> | ||||||
/// <param name="Exception">The exception</param> | ||||||
public record ExceptionSignal(IActivity Activity, Exception Exception); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm questioning whether we should report an incident if an exception was handled. What are your thoughts on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good question. I think if the user chooses Continue With Incidents Strategy, does he still need to add Catch Activity.If Catch Activity is not added, there will be no impact. If it is added, it means he needs this report.