Skip to content

Commit

Permalink
UX: Handle non-fatal exceptions for send and receive to show it on mo…
Browse files Browse the repository at this point in the history
…del card level (#65)
  • Loading branch information
oguzhankoral authored Jul 23, 2024
1 parent a554a2a commit c639fcb
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 53 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using Speckle.Autofac;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
using Speckle.Connectors.DUI.Models;
using Speckle.Connectors.DUI.Models.Card;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.ArcGIS.Bindings;

Expand Down Expand Up @@ -66,16 +66,17 @@ public async Task Receive(string modelCardId)
receiveOperationResults.ConversionResults
);
}
catch (TransportException e)
{
Commands.SetModelError(modelCardId, e);
}
// Catch here specific exceptions if they related to model card.
catch (OperationCanceledException)
{
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
// SWALLOW -> UI handles it immediately, so we do not need to handle anything for now!
// Idea for later -> when cancel called, create promise from UI to solve it later with this catch block.
// So have 3 state on UI -> Cancellation clicked -> Cancelling -> Cancelled
return;
}
catch (Exception e) when (!e.IsFatal()) // UX reasons - we will report operation exceptions as model card error.
{
Commands.SetModelError(modelCardId, e);
}
}

public void CancelReceive(string modelCardId) => _cancellationManager.CancelOperation(modelCardId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Mapping;
using ArcGIS.Desktop.Mapping.Events;
using Speckle.Autofac;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.ArcGIS.Filters;
using Speckle.Connectors.DUI.Bindings;
Expand All @@ -17,7 +18,6 @@
using Speckle.Connectors.Utils.Caching;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.ArcGIS.Bindings;

Expand Down Expand Up @@ -356,20 +356,17 @@ public async Task Send(string modelCardId)

Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults);
}
// Catch here specific exceptions if they related to model card.
catch (SpeckleSendFilterException e)
catch (OperationCanceledException)
{
Commands.SetModelError(modelCardId, e);
// SWALLOW -> UI handles it immediately, so we do not need to handle anything for now!
// Idea for later -> when cancel called, create promise from UI to solve it later with this catch block.
// So have 3 state on UI -> Cancellation clicked -> Cancelling -> Cancelled
return;
}
catch (TransportException e)
catch (Exception e) when (!e.IsFatal()) // UX reasons - we will report operation exceptions as model card error.
{
Commands.SetModelError(modelCardId, e);
}
catch (OperationCanceledException)
{
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
return;
}
}

public void CancelSend(string modelCardId) => _cancellationManager.CancelOperation(modelCardId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Speckle.Autofac;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.Autocad.HostApp;
using Speckle.Connectors.DUI.Bindings;
Expand All @@ -6,7 +7,6 @@
using Speckle.Connectors.DUI.Models.Card;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Autocad.Bindings;

Expand Down Expand Up @@ -72,13 +72,14 @@ public async Task Receive(string modelCardId)

Commands.SetModelReceiveResult(modelCardId, operationResults.BakedObjectIds, operationResults.ConversionResults);
}
// Catch here specific exceptions if they related to model card.
catch (OperationCanceledException)
{
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
// SWALLOW -> UI handles it immediately, so we do not need to handle anything for now!
// Idea for later -> when cancel called, create promise from UI to solve it later with this catch block.
// So have 3 state on UI -> Cancellation clicked -> Cancelling -> Cancelled
return;
}
catch (TransportException e)
catch (Exception e) when (!e.IsFatal()) // UX reasons - we will report operation exceptions as model card error.
{
Commands.SetModelError(modelCardId, e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Autodesk.AutoCAD.DatabaseServices;
using Speckle.Autofac;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.Autocad.HostApp;
using Speckle.Connectors.Autocad.HostApp.Extensions;
Expand All @@ -13,7 +14,6 @@
using Speckle.Connectors.Utils.Caching;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Autocad.Bindings;

Expand Down Expand Up @@ -169,17 +169,14 @@ private async Task SendInternal(string modelCardId)

Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults);
}
// Catch here specific exceptions if they related to model card.
catch (OperationCanceledException)
{
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
// SWALLOW -> UI handles it immediately, so we do not need to handle anything for now!
// Idea for later -> when cancel called, create promise from UI to solve it later with this catch block.
// So have 3 state on UI -> Cancellation clicked -> Cancelling -> Cancelled
return;
}
catch (TransportException e)
{
Commands.SetModelError(modelCardId, e);
}
catch (SpeckleSendFilterException e)
catch (Exception e) when (!e.IsFatal()) // UX reasons - we will report operation exceptions as model card error.
{
Commands.SetModelError(modelCardId, e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Speckle.Autofac;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
Expand All @@ -8,7 +9,6 @@
using Speckle.Connectors.Utils.Builders;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Revit.Bindings;

Expand Down Expand Up @@ -73,14 +73,15 @@ public async Task Receive(string modelCardId)
conversionResults.ConversionResults
);
}
catch (TransportException e)
catch (Exception e) when (!e.IsFatal()) // UX reasons - we will report operation exceptions as model card error.
{
Commands.SetModelError(modelCardId, e);
}
// Catch here specific exceptions if they related to model card.
catch (OperationCanceledException)
{
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
// SWALLOW -> UI handles it immediately, so we do not need to handle anything for now!
// Idea for later -> when cancel called, create promise from UI to solve it later with this catch block.
// So have 3 state on UI -> Cancellation clicked -> Cancelling -> Cancelled
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Autodesk.Revit.DB;
using Speckle.Autofac;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
Expand All @@ -13,7 +14,6 @@
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Converters.RevitShared.Helpers;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Revit.Bindings;

Expand Down Expand Up @@ -113,17 +113,15 @@ public async Task Send(string modelCardId)

Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults);
}
// Catch here specific exceptions if they related to model card.
catch (SpeckleSendFilterException e)
{
Commands.SetModelError(modelCardId, e);
}
catch (TransportException e)
catch (Exception e) when (!e.IsFatal()) // UX reasons - we will report operation exceptions as model card error.
{
Commands.SetModelError(modelCardId, e);
}
catch (OperationCanceledException)
{
// SWALLOW -> UI handles it immediately, so we do not need to handle anything for now!
// Idea for later -> when cancel called, create promise from UI to solve it later with this catch block.
// So have 3 state on UI -> Cancellation clicked -> Cancelling -> Cancelled
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Speckle.Autofac.DependencyInjection;
using Speckle.Autofac;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
using Speckle.Connectors.DUI.Models;
Expand All @@ -7,7 +8,6 @@
using Speckle.Connectors.Utils.Builders;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Rhino7.Bindings;

Expand Down Expand Up @@ -72,14 +72,15 @@ public async Task Receive(string modelCardId)
conversionResults.ConversionResults
);
}
catch (TransportException e)
catch (Exception e) when (!e.IsFatal()) // UX reasons - we will report operation exceptions as model card error.
{
Commands.SetModelError(modelCardId, e);
}
// Catch here specific exceptions if they related to model card.
catch (OperationCanceledException)
{
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
// SWALLOW -> UI handles it immediately, so we do not need to handle anything for now!
// Idea for later -> when cancel called, create promise from UI to solve it later with this catch block.
// So have 3 state on UI -> Cancellation clicked -> Cancelling -> Cancelled
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Rhino;
using Rhino.Commands;
using Rhino.DocObjects;
using Speckle.Autofac;
using Speckle.Autofac.DependencyInjection;
using Speckle.Connectors.DUI.Bindings;
using Speckle.Connectors.DUI.Bridge;
Expand All @@ -13,7 +14,6 @@
using Speckle.Connectors.Utils.Caching;
using Speckle.Connectors.Utils.Cancellation;
using Speckle.Connectors.Utils.Operations;
using Speckle.Core.Transports;

namespace Speckle.Connectors.Rhino7.Bindings;

Expand Down Expand Up @@ -161,18 +161,15 @@ public async Task Send(string modelCardId)

Commands.SetModelSendResult(modelCardId, sendResult.RootObjId, sendResult.ConversionResults);
}
// Catch here specific exceptions if they related to model card.
catch (SpeckleSendFilterException e)
{
Commands.SetModelError(modelCardId, e);
}
catch (TransportException e)
catch (Exception e) when (!e.IsFatal()) // UX reasons - we will report operation exceptions as model card error.
{
Commands.SetModelError(modelCardId, e);
}
catch (OperationCanceledException)
{
// SWALLOW -> UI handles it immediately, so we do not need to handle anything
// SWALLOW -> UI handles it immediately, so we do not need to handle anything for now!
// Idea for later -> when cancel called, create promise from UI to solve it later with this catch block.
// So have 3 state on UI -> Cancellation clicked -> Cancelling -> Cancelled
return;
}
}
Expand Down

0 comments on commit c639fcb

Please sign in to comment.