From 1f59f01c465bf3b036a62ecf6d460dfb187cfd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuzhan=20Koral?= <45078678+oguzhankoral@users.noreply.github.com> Date: Mon, 27 May 2024 16:42:26 +0300 Subject: [PATCH] Chore (dui3): error message from inner exception on sync functions (#3441) * Pass inner exception message if it is thrown on SYNC function * Extend error details --- .../Speckle.Connectors.DUI/Bridge/BrowserBridge.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs index 5050f652e3..ba25335a97 100644 --- a/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs +++ b/DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using Microsoft.Extensions.Logging; using Speckle.Connectors.Utils; +using Speckle.Core.Models.Extensions; namespace Speckle.Connectors.DUI.Bridge; @@ -255,7 +256,17 @@ private void ExecuteMethod(string methodName, string requestId, string args) /// private void ReportUnhandledError(string requestId, Exception e) { - var errorDetails = new { e.Message, Error = e.ToString() }; + var message = e.Message; + if (e is TargetInvocationException tie) // Exception on SYNC function calls. Message should be passed from inner exception since it is wrapped. + { + message = tie.InnerException?.Message; + } + var errorDetails = new + { + Message = message, // Topmost message + Error = e.ToFormattedString(), // All messages from exceptions + StackTrace = e.ToString() + }; var serializedError = JsonConvert.SerializeObject(errorDetails, _serializerOptions); NotifyUIMethodCallResultReady(requestId, serializedError);