diff --git a/src/OpenApi.Client.Cli/Commands/GenerateCommand.cs b/src/OpenApi.Client.Cli/Commands/GenerateCommand.cs index 7e271b6..dadc5d4 100644 --- a/src/OpenApi.Client.Cli/Commands/GenerateCommand.cs +++ b/src/OpenApi.Client.Cli/Commands/GenerateCommand.cs @@ -80,16 +80,25 @@ SerializationResultError serializationResultError in serializationResult.Errors AnsiConsole.MarkupLine($"[red]Error: {generatorResultError.Message}[/]"); } - return -1; + return -3; } generatedSource = generatorResult.Result; - await File.WriteAllTextAsync( - settings.Output, - generatedSource, - cancellationTokenSource.Token - ); + try + { + await File.WriteAllTextAsync( + settings.Output, + generatedSource, + cancellationTokenSource.Token + ); + } + catch (Exception e) + { + AnsiConsole.MarkupLine($"[red]Error: {e.Message}[/]"); + + return -4; + } return 0; }