Skip to content

Commit

Permalink
Check for errors while saving
Browse files Browse the repository at this point in the history
  • Loading branch information
pomianowski committed May 30, 2024
1 parent f243add commit d97a3ee
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/OpenApi.Client.Cli/Commands/GenerateCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d97a3ee

Please sign in to comment.