Skip to content

Commit

Permalink
Small tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
JR-Morgan committed Jun 19, 2024
1 parent d91528e commit fad5d5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ public Result([NotNull] Exception? result)
public sealed class TopLevelExceptionHandler
{
private readonly ILogger<TopLevelExceptionHandler> _logger;
private readonly IBridge? _bridge;
private readonly IBridge _bridge;

private const string UNHANDLED_LOGGER_TEMPLATE = "An unhandled Exception occured";

public TopLevelExceptionHandler(ILoggerFactory loggerFactory, IBridge? bridge = null)
public TopLevelExceptionHandler(ILoggerFactory loggerFactory, IBridge bridge)
{
_logger = loggerFactory.CreateLogger<TopLevelExceptionHandler>();
_bridge = bridge;
Expand Down Expand Up @@ -89,17 +90,6 @@ public Result<T> CatchUnhandled<T>(Func<T> function)
return CatchUnhandled(() => Task.FromResult(function.Invoke())).Result;
}

/// <inheritdoc cref="CatchUnhandled(Action)"/>
public async Task CatchUnhandled(Func<Task> function)
{
await CatchUnhandled<object?>(async () =>
{
await function.Invoke().ConfigureAwait(false);
return null;
})
.ConfigureAwait(false);
}

///<inheritdoc cref="CatchUnhandled{T}(Func{T})"/>
[SuppressMessage(
"Design",
Expand Down Expand Up @@ -128,7 +118,7 @@ public async Task<Result<T>> CatchUnhandled<T>(Func<Task<T>> function)
}

private void SetGlobalNotification(ToastNotificationType type, string title, string message, bool autoClose) =>
_bridge?.Send(
_bridge.Send(
BasicConnectorBindingCommands.SET_GLOBAL_NOTIFICATION, //TODO: We could move these constants into a DUI3 constants static class
new
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void AddConnectorUtils(this SpeckleContainerBuilder builder)
builder.AddScoped<ReceiveOperation>();

// POC: will likely need refactoring with our reporting pattern.
//TODO: Logger will likly be removed from Core, we'll plan to figure out the config later...
//TODO: Logger will likely be removed from Core, we'll plan to figure out the config later...
var serilogLogger = SpeckleLog.Logger;

ILoggerFactory loggerFactory = new LoggerFactory().AddSerilog(serilogLogger);
Expand Down

0 comments on commit fad5d5f

Please sign in to comment.