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
raise an error on warnings in tests #812
base: main
Are you sure you want to change the base?
Conversation
This is an experiment to see what will happen. |
9ae2a52
to
77d1830
Compare
@dlemstra I've been able to fix most of the warnings on this branch, but there are still a couple that I'm not sure about. Do you have any idea on the remaining ones? |
Just pushed some extra changes to fix the errors. Now wondering if we should not make a setting for"treat warning as errors" in the code (instead of overriding stderr.write) so our users can also do this? The following 'hack' could make this possible: void
rm_warning_handler(const ExceptionType severity, const char *reason, const char *description)
{
if (getenv("RMAGICK_WARNING_IS_ERROR"))
{
rm_error_handler(severity, reason, description);
return;
}
rb_warning("RMagick: %s%s%s",
GetLocaleExceptionMessage(severity, reason),
description ? ": " : "",
description ? GetLocaleExceptionMessage(severity, description) : "");
} Or we could introduce a new method that sets a variable that is used here. Your thoughts? |
Nice! Thanks for looking into it. I wonder, would it be reasonable to just throw an error in this cases rather than allowing them to configure it? If they're using the library wrong, I guess my preference would be to fail fast and loud. Warnings have a way of slipping through the cracks. I suppose we could also have something like your suggestion as a transitional tool:
|
Maybe it would be better to allow a user to set warning handling to one of the following values: |
Yeah, I guess it depends on the severity of it. In general, if they're using the library wrong I'd prefer an error. If it's just something that should work but might produce results that are a little odd, maybe a warning makes more sense. Even in those cases, though, I might still throw an error and push them to be more explicit about what they want. If they don't care, they can always rescue the error in their code. It might be more productive to discuss these on a case-by-case basis, though. |
I am just a bit worried that this will break existing code of a user. Maybe we could still allow the 3 choices and set the default to raise an error? |
Yeah, that makes sense. I think it would be important to have a transition plan. Rather than immediately starting to throw an error by default, we probably want to default it to warning like it does now, and allow a user to configure it. If we want to make throwing an error the default, we can add a deprecation warning in the 4.x version and in 5.0 we can make it the new default. |
351c3e4
to
41d7467
Compare
41d7467
to
782b539
Compare
782b539
to
f32d433
Compare
f32d433
to
9247682
Compare
No description provided.