Merge pull request #200 from Sergio0694/samples/error-handling-improvements
Samples/error handling improvements
このコミットが含まれているのは:
8ファイル変更
+50
-17
検索条件に一致するファイルはありません
@@ -9,6 +9,7 @@
|
||||
<Import_RootNamespace>ComputeSharp.SwapChain.Core.Shared</Import_RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Constants\Error.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Constants\Event.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\RenderingPauseConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Converters\ResolutionScaleConverter.cs" />
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace ComputeSharp.SwapChain.Core.Constants;
|
||||
|
||||
/// <summary>
|
||||
/// A <see langword="class"/> with the collection of tracked errors for analytics.
|
||||
/// </summary>
|
||||
public static class Error
|
||||
{
|
||||
public const string RenderingFailedOnMainPanel = "[SHELL] RenderingFailed (main panel)";
|
||||
public const string RenderingFailedOnSelectionPanel = "[SHELL] RenderingFailed (selection panel)";
|
||||
}
|
||||
@@ -12,6 +12,4 @@ public static class Event
|
||||
public const string IsRenderingPausedChanged = "[SETTINGS] IsRenderingPaused";
|
||||
public const string OpenShaderSelectionPanel = "[SHELL] Open ShaderSelectionPanel";
|
||||
public const string CloseShaderSelectionPanel = "[SHELL] Close ShaderSelectionPanel";
|
||||
public const string RenderingFailedOnMainPanel = "[SHELL] RenderingFailed (main panel)";
|
||||
public const string RenderingFailedOnSelectionPanel = "[SHELL] RenderingFailed (selection panel)";
|
||||
}
|
||||
@@ -30,12 +30,11 @@ public sealed class DebugAnalyticsService : IAnalyticsService
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Log(string title, Exception exception, params (string Property, object? Value)[]? data)
|
||||
public void Log(Exception exception, params (string Property, object? Value)[]? data)
|
||||
{
|
||||
StringBuilder builder = new();
|
||||
|
||||
builder.AppendLine($"[EXCEPTION]: \"{title}\"");
|
||||
builder.AppendLine($">> Type: \"{exception.GetType()}\"");
|
||||
builder.AppendLine($"[EXCEPTION]: \"{exception.GetType()}\"");
|
||||
builder.AppendLine(">> Stack trace");
|
||||
builder.AppendLine(exception.StackTrace);
|
||||
|
||||
|
||||
@@ -17,10 +17,9 @@ public interface IAnalyticsService
|
||||
void Log(string title, params (string Property, object? Value)[]? data);
|
||||
|
||||
/// <summary>
|
||||
/// Logs an exception with a specified title and optional properties.
|
||||
/// Logs an exception with optional properties.
|
||||
/// </summary>
|
||||
/// <param name="title">The title of the event to track.</param>
|
||||
/// <param name="exception">The exception that has been thrown.</param>
|
||||
/// <param name="data">The optional event properties.</param>
|
||||
void Log(string title, Exception exception, params (string Property, object? Value)[]? data);
|
||||
void Log(Exception exception, params (string Property, object? Value)[]? data);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public sealed class AppCenterService : IAnalyticsService
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Log(string title, Exception exception, params (string Property, object? Value)[]? data)
|
||||
public void Log(Exception exception, params (string Property, object? Value)[]? data)
|
||||
{
|
||||
Crashes.TrackError(exception, GetProperties(data));
|
||||
}
|
||||
|
||||
@@ -6,15 +6,11 @@
|
||||
xmlns:computesharp="using:ComputeSharp.Uwp"
|
||||
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
|
||||
xmlns:converters="using:ComputeSharp.SwapChain.Core.Converters"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:media="using:Microsoft.Toolkit.Uwp.UI.Media"
|
||||
xmlns:models="using:ComputeSharp.SwapChain.Core.Models"
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
|
||||
d:DesignHeight="300"
|
||||
d:DesignWidth="400"
|
||||
SizeChanged="UserControl_SizeChanged"
|
||||
mc:Ignorable="d">
|
||||
SizeChanged="UserControl_SizeChanged">
|
||||
|
||||
<Grid x:Name="Root">
|
||||
<Grid.Resources>
|
||||
@@ -228,5 +224,31 @@
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Top"
|
||||
Fill="Transparent" />
|
||||
|
||||
<!-- Info bar -->
|
||||
<muxc:InfoBar
|
||||
x:Name="RenderingErrorInfoBar"
|
||||
Title="Rendering error"
|
||||
Margin="80"
|
||||
Message="There was an error that caused the rendering to fail. Try pausing and starting the rendering again, or restarting the app. If the issue persists, please report it by opening an issue on GitHub."
|
||||
Severity="Error">
|
||||
<muxc:InfoBar.ActionButton>
|
||||
<HyperlinkButton Content="Report the issue" NavigateUri="https://github.com/Sergio0694/ComputeSharp/issues" />
|
||||
</muxc:InfoBar.ActionButton>
|
||||
<animations:Implicit.ShowAnimations>
|
||||
<animations:OpacityAnimation
|
||||
From="0"
|
||||
To="1.0"
|
||||
Duration="0:0:0.5" />
|
||||
<animations:TranslationAnimation
|
||||
From="0,20,0"
|
||||
To="0"
|
||||
Duration="0:0:0.5" />
|
||||
</animations:Implicit.ShowAnimations>
|
||||
<animations:Implicit.HideAnimations>
|
||||
<animations:OpacityAnimation To="0" Duration="0:0:0.5" />
|
||||
<animations:TranslationAnimation To="0,20,0" Duration="0:0:0.5" />
|
||||
</animations:Implicit.HideAnimations>
|
||||
</muxc:InfoBar>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -52,12 +52,16 @@ public sealed partial class MainView : UserControl
|
||||
// Logs rendering failed in the main panel
|
||||
private void MainShaderPanel_RenderingFailed(AnimatedComputeShaderPanel sender, Exception args)
|
||||
{
|
||||
Ioc.Default.GetRequiredService<IAnalyticsService>().Log(Event.RenderingFailedOnMainPanel, args);
|
||||
Ioc.Default.GetRequiredService<IAnalyticsService>().Log(args, (nameof(Error), Error.RenderingFailedOnMainPanel));
|
||||
|
||||
RenderingErrorInfoBar.IsOpen = true;
|
||||
}
|
||||
|
||||
// Logs rendering failed in a secondary panel
|
||||
private void SelectionShaderPanel_RenderingFailed(AnimatedComputeShaderPanel sender, Exception args)
|
||||
{
|
||||
Ioc.Default.GetRequiredService<IAnalyticsService>().Log(Event.RenderingFailedOnSelectionPanel, args);
|
||||
Ioc.Default.GetRequiredService<IAnalyticsService>().Log(args, (nameof(Error), Error.RenderingFailedOnSelectionPanel));
|
||||
|
||||
RenderingErrorInfoBar.IsOpen = true;
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする