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

Use trigger_error() for errors #174

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

haszi
Copy link
Contributor

@haszi haszi commented Oct 26, 2024

Use trigger_error() for triggering the error handler for errors instead of the custom function v(). vsprintf() is used with some errors as this function is used in function v() where formatted strings are being passed to the error handler.

I think this change makes sense semantically and will help with separating the intertwined error handling/info message printing of PhD.

@cmb69
Copy link
Member

cmb69 commented Oct 26, 2024

Hmm, E_USER_ERROR is deprecated as of PHP 8.4.0. Not sure if this is a good temporary solution.

@haszi
Copy link
Contributor Author

haszi commented Oct 26, 2024

Hmm, E_USER_ERROR is deprecated as of PHP 8.4.0. Not sure if this is a good temporary solution.

I completely forgot about that deprecation.

What do you think would be a good fit here? Using something like E_RECOVERABLE_ERROR?

@cmb69
Copy link
Member

cmb69 commented Oct 26, 2024

I think you can only pass E_USER_* to trigger_error(). I haven't looked at the code, but can we throw some exception and catch that in an exception handler?

@haszi
Copy link
Contributor Author

haszi commented Oct 26, 2024

I think you can only pass E_USER_* to trigger_error().

You're right, again. And without E_USER_ERROR there is no way to signal to the error handler that we need to bail out after the error message. :-(

I haven't looked at the code, but can we throw some exception and catch that in an exception handler?

I'm trying to avoid switching PhD from errors to exceptions at this stage. I would really prefer merging this, even if it's a just temporary solution, untangling error handling and info message output, and take it from there one step at a time.

Alternatively, I can add a some sort of generic PhD exception, let it bubble up to render.php, catch it there to display the error and then bail out from there. Would that work too for now?

@cmb69
Copy link
Member

cmb69 commented Oct 26, 2024

I'm trying to avoid switching PhD from errors to exceptions at this stage. I would really prefer merging this, even if it's a just temporary solution, untangling error handling and info message output, and take it from there one step at a time.

Taking one step at a time is usually a good idea. :)

Alternatively, I can add a some sort of generic PhD exception, let it bubble up to render.php, catch it there to display the error and then bail out from there. Would that work too for now?

If that doesn't require more complex code changes, I'm fine with it. But don't waste too much time, if it is only an intermediate step.

Maybe @Girgias and/or @jimwins have some suggestions.

@Girgias
Copy link
Member

Girgias commented Oct 27, 2024

I am fine to use E_USER_ERROR as a temporary measure to help untangle the current mess. :)

Copy link
Member

@jimwins jimwins left a comment

Choose a reason for hiding this comment

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

It's just a deprecation (and we're just on 8.2 with the PHP systems), so I'm fine with this as an interim step to cleaning up the code.

@Girgias Girgias merged commit 0364e4f into php:master Oct 29, 2024
9 checks passed
@haszi haszi deleted the Use-trigger_error-for-errors branch November 10, 2024 20:02
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