HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
Errors.php
Go to the documentation of this file.
1 <?php
2 class Errors {
3  public static function isError($jsonRaw) {
4  $json = CJSON::decode($jsonRaw);
5  if (is_null($json)) {
6  throw new CHttpException('DCC',"Can't access DC Client. Please, check the \"PathToApi\" string in config.ini");
7  }
8  if (isset($json['errorCode'])) {
9  $nodes = explode(';', $json['errorCode']);
10  foreach ($nodes as $k => $v) {
11  if(($v != 0) || ($v != 0)) {
12  return $json['errorMessage'];
13  }
14  }
15  }
16  if (isset($json['error_code'])) {
17  $nodes = explode(';', $json['error_code']);
18  foreach ($nodes as $k => $v) {
19  if(($v != 0) || ($v != 0)) {
20  return $json['error_message'];
21  }
22  }
23  }
24  if ((isset($json['itemsList'][0]['errorCode'])) && ($json['itemsList'][0]['errorCode'] != 0)) {
25  return $json['itemsList'][0]['errorMessage'];
26  } elseif ((isset($json['itemsList'][0]['itemObject']['errorCode'])) && ($json['itemsList'][0]['itemObject']['errorCode'] != 0)) {
27  return $json['itemsList'][0]['itemObject']['errorMessage'];
28  }
29  return 0;
30  }
31 }