Skip to content

Added lazy evaluation functionality to error printer.#510

Merged
hoytak merged 2 commits intomainfrom
hoytak/250924-error-printer-update
Sep 29, 2025
Merged

Added lazy evaluation functionality to error printer.#510
hoytak merged 2 commits intomainfrom
hoytak/250924-error-printer-update

Conversation

@hoytak
Copy link
Collaborator

@hoytak hoytak commented Sep 24, 2025

Currently, the full message given to a function in error_printer must be always created. This causes extra work when there are no errors if the message should contain additional data.

This PR introduces _fn versions of the existing functions that call a given function on demand to obtain the message. Thus .warn_error_fn(|| format!("Error processing {context}")) would only allocate and create the error string when an error needs to be logged.

Copy link
Contributor

@assafvayner assafvayner left a comment

Choose a reason for hiding this comment

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

🚢 this is useful generally, glad that you added it.

@assafvayner
Copy link
Contributor

FYI @jgodlew too

Copy link
Contributor

@jgodlew jgodlew left a comment

Choose a reason for hiding this comment

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

LGTM!

@hoytak hoytak merged commit 4176674 into main Sep 29, 2025
6 checks passed
@hoytak hoytak deleted the hoytak/250924-error-printer-update branch September 29, 2025 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants