feat: fallback to static AnsiConsole if exception occurs before registered in DI container
This commit is contained in:
@@ -18,9 +18,9 @@ internal static class HostBuilderExtensions
|
||||
app.Configure(static c =>
|
||||
c.SetExceptionHandler(static (ex, resolver) =>
|
||||
{
|
||||
var console = resolver?.Resolve(typeof(IAnsiConsole)) as IAnsiConsole;
|
||||
console?.MarkupLine($"[red]An error occurred while executing the command:[/]");
|
||||
console?.WriteException(ex, ExceptionFormats.ShortenEverything);
|
||||
var console = resolver?.Resolve(typeof(IAnsiConsole)) as IAnsiConsole ?? AnsiConsole.Console;
|
||||
console.MarkupLine($"[red]An error occurred while executing the command:[/]");
|
||||
console.WriteException(ex, ExceptionFormats.ShortenEverything);
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ try
|
||||
services.AddSingleton(TimeProvider.System);
|
||||
services.AddSingleton<IAudioExtractor, AudioExtractor>();
|
||||
services.AddSingleton<ITranscriber, WhisperTranscriber>();
|
||||
services.AddSingleton<ITranscriptAnalyzer, GeminiAnalyzer>(sp =>
|
||||
services.AddSingleton<ITranscriptAnalyzer, GeminiAnalyzer>(static sp =>
|
||||
{
|
||||
const string modelOptionName = "Model";
|
||||
const string keyOptionName = "ApiKey";
|
||||
|
||||
Reference in New Issue
Block a user