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:
[x] Commented on code changes inline explain the reasoning behind the approach
[x] Reviewed the test cases added for completeness and possible points for discussion
[x] A changelog entry was added for the goal of this pull request
[x] Check the scope of the changeset - is everything in the diff required for the pull request?
This pull request is ready for:
[ ] Initial review of the intended approach, not yet feature complete
[ ] Structural review of the classes, functions, and properties modified
[x] Final review
For the pull request reviewer(s), this changeset has been reviewed for:
[ ] Consistency across platforms for structures or concepts added or modified
[ ] Consistency between the changeset and the goal stated above
[ ] Internal consistency with the rest of the library - is there any overlap between existing interfaces and any which have been added?
[ ] Usage friction - is the proposed change in usage cumbersome or complicated?
[ ] Performance and complexity - are there any cases of unexpected O(n^3) when iterating, recursing, flat mapping, etc?
[ ] Concurrency concerns - if components are accessed asynchronously, what issues will arise
[ ] Thoroughness of added tests and any missing edge cases
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:
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
onnull
, which always returns falseThis 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 allChangeset
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 pageDiscussion
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: