Commit a26d0053 authored by Nick Daugherty's avatar Nick Daugherty
Browse files

Overloaded __call() to transparently handle Exceptions in production

Most Exceptions are thrown from API timeouts - which are more difficult
to find in testing.

To prevent fatals in production, this transparently handles Exceptions
in __call(), returning an empty array instead.

Room for improvement - store the Exception information as a WP_Error in
a protected var.

- Determine what the expected response type is. For example, status
updates don't expect an array response - an appropriate response should
be returned for the request.
parent 15d9226e
......@@ -31,6 +31,20 @@ class WP_Codebird extends Codebird {
return self::$_instance;
* Overload magic __call() to transparently intercept Exceptions
* Most exceptions encountered in production are API timeouts - this will
* transparently handle these Exceptions to prevent fatal errors
public function __call( $function, $arguments ) {
try {
return parent::__call( $function, $arguments );
} catch ( Exception $e ) {
return array();
* Calls the API using Wordpress' HTTP API.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment