Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Improve vformat error reporting on sprintf failure #93897

Merged

Conversation

akien-mga
Copy link
Member

@akien-mga akien-mga commented Jul 3, 2024

And fix a few occurrences of formatting errors that led me to this.

Example from the cases handled here:

ERROR: Formatting error in string "Unable to convert array index %i from "%s" to "%s".": unsupported format character.
   at: vformat (./core/variant/variant.h:860)

@akien-mga akien-mga added this to the 4.3 milestone Jul 3, 2024
@akien-mga akien-mga requested a review from a team as a code owner July 3, 2024 12:23
@akien-mga akien-mga added cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release labels Jul 3, 2024
@akien-mga akien-mga changed the title Core: Improve vformat error reporting on sprintf failure Core: Improve vformat error reporting on sprintf failure Jul 3, 2024
@akien-mga akien-mga changed the title Core: Improve vformat error reporting on sprintf failure Core: Improve vformat error reporting on sprintf failure Jul 3, 2024
@@ -857,7 +857,7 @@ String vformat(const String &p_text, const VarArgs... p_args) {
bool error = false;
String fmt = p_text.sprintf(args_array, &error);

ERR_FAIL_COND_V_MSG(error, String(), fmt);
ERR_FAIL_COND_V_MSG(error, String(), String("Formatting error in string \"") + p_text + "\": " + fmt + ".");
Copy link
Member Author

Choose a reason for hiding this comment

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

Not using vformat here to avoid recursive calling.

And fix a few occurrences of formatting errors that led me to this.
@akien-mga akien-mga force-pushed the vformat-better-error-message branch from 243ca77 to 496b7b8 Compare July 4, 2024 08:55
@akien-mga akien-mga requested a review from a team as a code owner July 4, 2024 08:55
@akien-mga akien-mga merged commit daba91d into godotengine:master Jul 8, 2024
18 checks passed
@akien-mga akien-mga deleted the vformat-better-error-message branch July 8, 2024 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release enhancement topic:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant