using Microsoft.Extensions.Logging;
using Speckle.Sdk;
namespace Speckle.Connectors.DUI.Logging;
///
/// These helper functions are designed because we are handling all s using the model card
/// But we still would like to discriminate the severity via logging.
/// If we ever decide to be more specific with our exception catching within bindings (to allow unexpected exceptions to bubble up to the top level)
/// then these functions likely won't be useful.
///
public static class HandledModelCardErrors
{
public static void LogModelCardHandledError(this ILogger logger, Exception ex)
{
LogLevel level = ex switch
{
SpeckleException => LogLevel.Warning,
_ => LogLevel.Error
};
logger.Log(level, ex, "{bindingType} operation was not successful", typeof(T));
}
}