keolo / mixpanel_client

Ruby interface to the Mixpanel Data API
MIT License
148 stars 72 forks source link

JSON error when Mixpanel API is down #5

Closed Hebo closed 12 years ago

Hebo commented 12 years ago

When the Mixpanel API is down for maintenance or whatever, API requests return HTML instead of JSON, causing json.parse to fail and the resulting error to bubble up to my application.

Can we tweak the MP API or put all mixpanel_client related errors in one namespace so I have only one thing to catch in my app?

Error

exception type JSON::ParserError

743: unexpected token at '<html> <head> <title>Mixpanel | Real-time Web Analytics, Funnel Analysis</title> [...] Your real-time analytics will be back soon. [...]</html> '
keolo commented 12 years ago

Hi Cev. I'm pretty tied up at the moment. This sounds like an improvement. If you fork and create a pull request, I'll merge it in. Thanks!

Hebo commented 12 years ago

I couldn't run the tests that use external dependencies, so I expect the one that requires an exception will fail.

You can catch all expected exceptions from the gem now with rescue Mixpanel::Error => e

keolo commented 12 years ago

Great. Thanks. I'll try to merge it in this week.

keolo commented 12 years ago

Your changes should now be available in version 2.0.2. Thanks!