Skip to content

Commit

Permalink
Chore (dui3): error message from inner exception on sync functions (#…
Browse files Browse the repository at this point in the history
…3441)

* Pass inner exception message if it is thrown on SYNC function

* Extend error details
  • Loading branch information
oguzhankoral authored May 27, 2024
1 parent 8fcf59a commit 1f59f01
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion DUI3-DX/DUI3/Speckle.Connectors.DUI/Bridge/BrowserBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -255,7 +256,17 @@ private void ExecuteMethod(string methodName, string requestId, string args)
/// </summary>
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);
Expand Down

0 comments on commit 1f59f01

Please sign in to comment.