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

Support opting out of the default [error] prefix #187

Merged
merged 1 commit into from
May 22, 2022
Merged

Support opting out of the default [error] prefix #187

merged 1 commit into from
May 22, 2022

Conversation

ken-matsui
Copy link
Contributor

toml11 prints error messages with the [error] prefix by default.
Defining TOML11_NO_ERROR_PREFIX will let toml11 omit the prefix regardless of colorized or not in case you would use a custom prefix, such as Error:.

#define TOML11_NO_ERROR_PREFIX

Without TOML11_NO_ERROR_PREFIX:

[error] value should be positive
 --> example.toml
 3 | num = -42
   |       ~~~ positive number required

With TOML11_NO_ERROR_PREFIX:

value should be positive
 --> example.toml
 3 | num = -42
   |       ~~~ positive number required

We are now able to customize the prefix like:

fmt::print("Error: {}", e.what());

This prints out:

Error: value should be positive
 --> example.toml
 3 | num = -42
   |       ~~~ positive number required

@ToruNiina ToruNiina merged commit fdb2285 into ToruNiina:master May 22, 2022
@ToruNiina
Copy link
Owner

This is a useful feature. Thank you!

@ken-matsui ken-matsui deleted the support-opting-out-of-error-prefix branch May 22, 2022 06:28
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.

2 participants