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

Unhandled exception causes fatal error when API secret isn't set #20

Closed
jslegers opened this issue Feb 27, 2015 · 10 comments
Closed

Unhandled exception causes fatal error when API secret isn't set #20

jslegers opened this issue Feb 27, 2015 · 10 comments

Comments

@jslegers
Copy link
Contributor

Because I had a typo in the field name referencing my API secret, I get the following fatal error:

Additional uncaught exception thrown while handling exception.

Original

SumoCoders\Teamleader\Exception: api-error on group 6151 in SumoCoders\Teamleader\Teamleader->doCall() (line 272 of /Users/inxco/Documents/www/drupalteamleader4/sites/all/vendor/SumoCoders/Teamleader/Teamleader.php).

Additional

Exception: theme() may not be called until all modules are loaded. in theme() (line 1017 of /Users/inxco/Documents/www/drupalteamleader4/includes/theme.inc).

It would be nice to trigger a more user friendly error message when an API secret or API group has not been defined instead of this error.

@carakas
Copy link
Contributor

carakas commented Oct 8, 2016

@jslegers can you create a PR for this if this is still an issue?

@jslegers
Copy link
Contributor Author

@carakas :

I no longer have a working Teamleader account nor any interest in using this library.

Heck, I haven't even been doing any PHP coding in months ;-)

@carakas
Copy link
Contributor

carakas commented Oct 10, 2016

Ok then I'll close this issue

@carakas carakas closed this as completed Oct 10, 2016
@jslegers
Copy link
Contributor Author

jslegers commented Oct 10, 2016

@carakas :

Shouldn't you first test whether you can reproduce the error before you close the issue?
I seriously doubt it has been fixed!

@carakas
Copy link
Contributor

carakas commented Oct 10, 2016

@jslegers they are constructor parameters, so in my opinion we can expect them to be there

@jslegers
Copy link
Contributor Author

@carakas :

After your initial setup, yes, you can expect them to be there.

A lot can go wrong during the initial setup, however, and useful help messages at this stage would make everyone's lives easier ;-)

@carakas
Copy link
Contributor

carakas commented Oct 10, 2016

I'll reopen it

@carakas carakas reopened this Oct 10, 2016
@carakas
Copy link
Contributor

carakas commented Oct 10, 2016

I still don't see how this could happen, since the initial setup is literally passing those values to the constructor

@turanct
Copy link

turanct commented Oct 10, 2016

It doesn't seem like the teamleader API lets us know that an authentication error occured? In that case, displaying the error they return is the only thing we can do... The only thing they let us know is:

  1. request was succesful code 200
  2. request failed code 400
  3. rate limits reached code 505

which aren't even great http response codes (see their api docs )

Furthermore, we can't check for correctness of the parameters when constructing the instance, so it seems to me like throwing an exception like this is the only reasonable way to go?

@jslegers
Copy link
Contributor Author

jslegers commented Oct 10, 2016

@carakas :

This error takes place when there's a mistake in your API secret or API group.

As I explained (in the first line), it happened to me due to a typo that was anything but obvious to spot :

Because I had a typo in the field name referencing my API secret, I get the following fatal error:

[...]

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

No branches or pull requests

4 participants