fix(central-ui): exception subtitle parses inner/generic exception names; pill+badge test (Task 11 review)
This commit is contained in:
@@ -104,7 +104,7 @@
|
||||
}
|
||||
@if (logs.Errors + logs.Warnings + logs.Info > 0)
|
||||
{
|
||||
<span class="fg-logs" data-test="flow-node-logs" title="@LogTitle(node)">
|
||||
<span class="fg-logs" data-test="flow-node-logs" title="@LogTitle(logs)">
|
||||
@if (logs.Errors > 0)
|
||||
{
|
||||
<i class="e">✕ @logs.Errors</i>
|
||||
|
||||
@@ -260,9 +260,9 @@ public partial class FlowGraphView : ComponentBase
|
||||
}
|
||||
|
||||
/// <summary>Hover text for the log badge — the non-zero levels only ("1 error, 2 warnings, 4 info").</summary>
|
||||
internal static string LogTitle(FlowLayoutNode n)
|
||||
internal static string LogTitle((int Errors, int Warnings, int Info) counts)
|
||||
{
|
||||
var (errors, warnings, info) = LogCounts(n.Step);
|
||||
var (errors, warnings, info) = counts;
|
||||
var parts = new List<string>(3);
|
||||
if (errors > 0) parts.Add($"{errors} error{(errors == 1 ? "" : "s")}");
|
||||
if (warnings > 0) parts.Add($"{warnings} warning{(warnings == 1 ? "" : "s")}");
|
||||
@@ -274,7 +274,10 @@ public partial class FlowGraphView : ComponentBase
|
||||
/// The subtitle a failed or timed-out step shows instead of its own: <c>{Type}: {message}</c>, where
|
||||
/// the type is the exception's name without its namespace, parsed from the first line of the captured
|
||||
/// <see cref="FlowStep.ErrorDetail"/> (a .NET <c>ToString()</c> opens with <c>Namespace.Type: message</c>).
|
||||
/// Falls back to the first line verbatim when it carries no <c>": "</c>, and to
|
||||
/// A wrapper's first line chains its inner exceptions with <c>" ---> "</c>; the LAST segment is taken,
|
||||
/// since the innermost exception is the one the script author has to act on. The namespace is stripped
|
||||
/// only from the head of the type name — any generic arity/argument suffix (<c>`1[System.String]</c>)
|
||||
/// is kept verbatim. Falls back to the line itself when it carries no <c>": "</c>, and to
|
||||
/// <see cref="FlowStep.ErrorMessage"/> when there is no detail. Null for every non-failed step.
|
||||
/// </summary>
|
||||
internal static string? ExceptionSubtitle(FlowStep s)
|
||||
@@ -283,6 +286,9 @@ public partial class FlowGraphView : ComponentBase
|
||||
if (string.IsNullOrWhiteSpace(s.ErrorDetail)) return s.ErrorMessage;
|
||||
|
||||
var first = s.ErrorDetail.Split('\n', 2)[0].TrimEnd('\r').Trim();
|
||||
// A wrapper (AggregateException, a rethrow) chains inner exceptions on the same line — the last is innermost.
|
||||
var inner = first.LastIndexOf(" ---> ", StringComparison.Ordinal);
|
||||
if (inner >= 0) first = first[(inner + " ---> ".Length)..].Trim();
|
||||
if (first.Length == 0) return s.ErrorMessage;
|
||||
|
||||
var split = first.IndexOf(": ", StringComparison.Ordinal);
|
||||
@@ -290,8 +296,12 @@ public partial class FlowGraphView : ComponentBase
|
||||
|
||||
var type = first[..split];
|
||||
var message = first[(split + 2)..];
|
||||
var dot = type.LastIndexOf('.');
|
||||
if (dot >= 0 && dot < type.Length - 1) type = type[(dot + 1)..];
|
||||
// Shorten only the leading namespace: everything from a generic marker on is part of the name.
|
||||
var generic = type.IndexOfAny(['`', '[']);
|
||||
var head = generic < 0 ? type : type[..generic];
|
||||
var dot = head.LastIndexOf('.');
|
||||
if (dot >= 0 && dot < head.Length - 1)
|
||||
type = head[(dot + 1)..] + (generic < 0 ? string.Empty : type[generic..]);
|
||||
return type + ": " + message;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user