Permalink
Browse files

php 5.2 support

  • Loading branch information...
thousandsofthem committed Apr 20, 2012
1 parent 91cdbaa commit 6483b08694b36877198730ce1d94899ddfdb98d5
Showing with 11 additions and 3 deletions.
  1. +11 −3 IronMQ.class.php
View
@@ -48,6 +48,10 @@ function __construct($error_code) {
case JSON_ERROR_SYNTAX:
$this->error = "Syntax error, malformed JSON";
break;
+ default:
+ $this->error = $error_code;
+ break;
+
}
parent::__construct();
}
@@ -485,9 +489,13 @@ private function debug($var_name, $variable){
private static function json_decode($response){
$data = json_decode($response);
- $json_error = json_last_error();
- if($json_error != JSON_ERROR_NONE) {
- throw new JSON_Exception($json_error);
+ if (function_exists('json_last_error')){
+ $json_error = json_last_error();
+ if($json_error != JSON_ERROR_NONE) {
+ throw new JSON_Exception($json_error);
+ }
+ }elseif($data === null){
+ throw new JSON_Exception("Common JSON error");
}
return $data;
}

0 comments on commit 6483b08

Please sign in to comment.