-
-
Notifications
You must be signed in to change notification settings - Fork 513
Define and document the best way to handle errors #2210
Copy link
Copy link
Open
Labels
Milestone
Description
In #2196, we shortly explored how to best handle errors. We quickly came to the realization that we need more insights. We should explore the possibilities we have a little better and also explore how other projects in the WordPress area do it.
Specifically, we should be able to answer the following question:
- Should we ever use
error_log()? - Under which conditions should we call
trigger_error()? - How does
WP_DEBUGaffect error handling? - What’s the best way for developers to hook into Timber to add Timber errors to a custom logging system? Should we use
set_error_handler()? - Which errors should be captured by existing logging systems or services (Query - Monitor, Bugsnag, etc.)?
And when we figured that out, we should document this in the Debugging Guide.
Notes
- When we use
error_log(), we log directly to the log. But when we usetrigger_error(), it first runs through error handlers set throughset_error_handler(). - The
set_error_handler()function is what plugins like Query Monitor or Bugsnag use to catch errors and handle them their way. For example, Bugsnag will send you emails with the error, which is very helpful. If we useerror_log(), these plugins can’t catch the errors. Errors might be lost in a log that nobody looks at. - The
doing_it_wrong_runanddeprecated_function_runactions are mainly used by testing suites to make the special tags like@expectedIncorrectUsageor@expectedDeprecatedwork.
Any ideas, insights, tips and hints are very welcome.
Reactions are currently unavailable