bugsnag / bugsnag-wordpress

BugSnag error monitoring for WordPress sites
http://wordpress.org/plugins/bugsnag/
GNU General Public License v2.0
20 stars 15 forks source link

Improve error message when methods are called with no api key set #47

Closed imjoehaines closed 4 years ago

imjoehaines commented 4 years ago

Goal

Currently if you call a method which should be forwarded on to the Bugnsag Client before you've provided an API Key, we error with the message:

Method foo does not exist on Bugsnag_Wordpress or Bugsnag_Client

This isn't true — the method might exist — but as we have no API Key we don't construct a Client so we test method_exists on null, which always returns false

This PR adds a check for an API Key in __call, so we can provide a better error message. We need to fail loudly in this case because if a user is calling configuration methods then presumably they expect Bugsnag to be working when actually it's not setup at all

Changeset

Tests

This was tested manually by adding a method call to functions.php (e.g. $bugsnagWordpress->setDebug(true);) and then removing the API Key from the Bugsnag settings page

Discussion

Alternative Approaches

Outstanding Questions

Linked issues

Related to #42

Review

For the submitter, initial self-review:

For the pull request reviewer(s), this changeset has been reviewed for: