Skip to content

Conversation

@fliiiix
Copy link
Contributor

@fliiiix fliiiix commented Dec 3, 2025

Builds on previews MR #8764 and returns proper error message when files fail to write.

eg something like this:

error:
  Unable to generate Python for monster_extra Could not save file /tmp/readonly/MyGame/__init__.py

//cc @jtdavis777 @aardappel

@github-actions github-actions bot added python c++ grpc codegen Involving generating code from schema labels Dec 3, 2025
@jtdavis777 jtdavis777 self-requested a review December 3, 2025 13:28
const char* RealFileSaver::AttemptSave(const char* name, const char* buf,
size_t len, bool binary) {
if (!SaveFile(name, buf, len, binary)) {
static std::string error_msg;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can have static std::string in this project. This will make the project non-modular in terms of memory management. Better to stick an err string in RealFileSaver ? Or, if we absolutely must do string formatting for these errors, probably the least bad would be to return a std::string by value from this function, where empty string means no error. But really, you are formatting name which is passed in by the called, so they already know the cause of the problem, so a non-formatted const char * may be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point i will update 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ codegen Involving generating code from schema grpc python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants