コード例 #1
0
ファイル: database.php プロジェクト: just-paja/fudjan
 function __construct()
 {
     $d = func_get_args();
     $msg = strtolower($d[0]);
     if (strpos($msg, 'duplicate') !== false || isset($d[1]) && strpos(strtolower($d[1]), 'duplicate') !== false) {
         array_unshift($d, 'Cannot insert data because of duplicate unique key.');
     } elseif (strpos($msg, 'syntax') !== false) {
         array_unshift($d, 'Cannot run query because of syntax error.');
     } elseif (strpos($msg, 'table') !== false && strpos($msg, 'exist')) {
         array_unshift($d, 'Table does not exist.');
     } elseif (strpos($msg, 'unknown column') === 0) {
         array_unshift($d, 'Missing column');
     } else {
         array_unshift($d, 'Unhandled database error');
     }
     parent::__construct(implode(', ', $d));
 }
コード例 #2
0
 /**
  * Make a new API Exception with the given result.
  *
  * @param array $result The result from the API server
  */
 public function __construct($result)
 {
     $this->result = $result;
     $code = isset($result['error_code']) ? $result['error_code'] : 0;
     if (isset($result['error_description'])) {
         // OAuth 2.0 Draft 10 style
         $msg = $result['error_description'];
     } else {
         if (isset($result['error']) && is_array($result['error'])) {
             // OAuth 2.0 Draft 00 style
             $msg = $result['error']['message'];
         } else {
             if (isset($result['error_msg'])) {
                 // Rest server style
                 $msg = $result['error_msg'];
             } else {
                 $msg = 'Unknown Error. Check getResult()';
             }
         }
     }
     parent::__construct($msg, $code);
 }