From c8363ddeb715efafb41e6f8eebf31b8d61bd0433 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 31 Jan 2019 11:05:19 +0100 Subject: [PATCH] Supply more detailed exception details. So we can display better errors in a designer. --- .../Remote/RemoteDesignerEntryPoint.cs | 12 +++++++++++- src/Avalonia.Remote.Protocol/DesignMessages.cs | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs index 09196e4fb7..67a93f3c9c 100644 --- a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs +++ b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs @@ -8,6 +8,7 @@ using Avalonia.Remote.Protocol; using Avalonia.Remote.Protocol.Designer; using Avalonia.Remote.Protocol.Viewport; using Avalonia.Threading; +using Portable.Xaml; namespace Avalonia.DesignerSupport.Remote { @@ -204,9 +205,18 @@ namespace Avalonia.DesignerSupport.Remote } catch (Exception e) { + var xamlException = e as XamlException; + s_transport.Send(new UpdateXamlResultMessage { - Error = e.ToString() + Error = e.ToString(), + Exception = new ExceptionDetails + { + ExceptionType = e.GetType().FullName, + Message = e.Message.ToString(), + LineNumber = xamlException?.LineNumber, + LinePosition = xamlException?.LinePosition, + } }); } } diff --git a/src/Avalonia.Remote.Protocol/DesignMessages.cs b/src/Avalonia.Remote.Protocol/DesignMessages.cs index f70bcef6b3..5ff16c574d 100644 --- a/src/Avalonia.Remote.Protocol/DesignMessages.cs +++ b/src/Avalonia.Remote.Protocol/DesignMessages.cs @@ -15,6 +15,7 @@ namespace Avalonia.Remote.Protocol.Designer { public string Error { get; set; } public string Handle { get; set; } + public ExceptionDetails Exception { get; set; } } [AvaloniaRemoteMessageGuid("854887CF-2694-4EB6-B499-7461B6FB96C7")] @@ -23,4 +24,11 @@ namespace Avalonia.Remote.Protocol.Designer public string SessionId { get; set; } } + public class ExceptionDetails + { + public string ExceptionType { get; set; } + public string Message { get; set; } + public int? LineNumber { get; set; } + public int? LinePosition { get; set; } + } }