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
Allow stack track logging on failing Result.Act() #64
base: main
Are you sure you want to change the base?
Conversation
@@ -85,7 +85,7 @@ public Result<TOut> Act<TOut>(Func<TModel, Result<TOut>> action) | |||
return new(outcome.IsValid | |||
? outcome.Value | |||
: default, | |||
((FixedMessages)Messages).AddRange(outcome.Messages)); | |||
((FixedMessages)Messages).AddRange(outcome.Messages).Add(ActFailed.New(outcome.IsValid))); |
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 think adding a new message might not be visible enough, especially if you have many other error messages. I would prefer to see something more in line with debugger breakpoints.
/// <inheritdoc /> | ||
public ValidationSeverity Severity | ||
=> Trace is { } | ||
? ValidationSeverity.Error |
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 think it would perhaps be beneficial to introduce a new severity for this (e.g. Debug
)
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.
Given:
/// <summary>The validation severity of a <see cref="IValidationMessage"/>.</summary>
public enum ValidationSeverity
{
/// <summary>Successful message (so no severity).</summary>
None = -1,
/// <summary>Informative message severity.</summary>
Info = 0,
/// <summary>Warning message severity.</summary>
Warning = 1,
/// <summary>Error message severity.</summary>
Error = 2,
}
That can be challenging. I already considered Info a better severity, but a new level might be problematic.
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 not entirely sure how this snippet is meant to show that adding a new severity is challenging? If you mean that the integer values of the enum are meant to also bear some meaning, then I would propose to make Debug
have the value of -2
, since the message is theoretically only present during debugging and is therefore similar to None
(except that it doesn't get filtered).
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.
-2
would indeed be the logical value. But there is at least 1 place that has logic stating: Severity > Severity.None
. In this case to add messages to a result to create. Furthermore, by making the value public, also other messages with a DEBUG severity can be created, I don't think I like that to happen.
From multiple channels, people have given the feedback that debugging longer chains of
.Act()
can be hard to debug. This PR is an attempt to improve the debugger experience.The main idea is to add a custom
IValidationMessage
that contains theStackTrace
once a.Act()
execution results in an invalid result.