Skip to content

Commit

Permalink
Some errors are strings, not objects. Accounting for strings/
Browse files Browse the repository at this point in the history
  • Loading branch information
cheyner committed Jul 27, 2015
1 parent 4be7782 commit 0626788
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions models/datasources/braintree_source.php
Expand Up @@ -322,7 +322,7 @@ public function create(&$model, $fields = null, $values = null) {
break;
}
} catch (Exception $e) {
$this->showError(print_r($e, true));
$this->showError($e);
return false;
}

Expand Down Expand Up @@ -695,17 +695,25 @@ public function showError($error) {
trigger_error($error, E_USER_WARNING);
} else {

$class = get_class($error);
$message = $error->getMessage();
$code = $error->getCode();
$file = $error->getFile();
$linenumber = $error->getLine();
if (is_string($error)) {

$this->log("Braintree Error: {$error}");

} else {

$public = Braintree_Configuration::publicKey();
$merchant_id = Braintree_Configuration::merchantId();
$environment = Braintree_Configuration::environment();
$class = get_class($error);
$message = $error->getMessage();
$code = $error->getCode();
$file = $error->getFile();
$linenumber = $error->getLine();

$this->log("Braintree Error: {$message}, {$code} in object {$class}, line number {$linenumber} in file {$file}. Configuration: public {$public}, merchant {$merchant_id}, env {$environment}.");
$public = Braintree_Configuration::publicKey();
$merchant_id = Braintree_Configuration::merchantId();
$environment = Braintree_Configuration::environment();

$this->log("Braintree Error: {$message}, {$code} in object {$class}, line number {$linenumber} in file {$file}. Configuration: public {$public}, merchant {$merchant_id}, env {$environment}.");

}

}

Expand Down

0 comments on commit 0626788

Please sign in to comment.