コード例 #1
0
ファイル: Results.inc.php プロジェクト: selenus/dataserver
 public function addFailure($index, $key, Exception $e)
 {
     if (isset($this->failed[$index])) {
         throw new Exception("Duplicate index '{$index}' for failure with key '{$key}'");
     }
     $this->failed[$index] = Zotero_Errors::parseException($e);
     $this->failed[$index]['key'] = $key;
     // Log loggable errors as they occur
     if (!empty($this->failed[$index]['log'])) {
         error_log($e);
     }
 }
コード例 #2
0
ファイル: ApiController.php プロジェクト: ergo70/dataserver
 public function handleException(Exception $e)
 {
     $error = Zotero_Errors::parseException($e);
     if (!empty($error['log'])) {
         $id = substr(md5(uniqid(rand(), true)), 0, 10);
         $str = date("D M j G:i:s T Y") . "  \n";
         $str .= "IP address: " . $_SERVER['REMOTE_ADDR'] . "  \n";
         if (isset($_SERVER['HTTP_X_ZOTERO_VERSION'])) {
             $str .= "Version: " . $_SERVER['HTTP_X_ZOTERO_VERSION'] . "  \n";
         }
         $str .= $_SERVER['REQUEST_METHOD'] . " " . $_SERVER['REQUEST_URI'] . "  \n";
         $str .= $error['exception'] . "  \n";
         // Show request body unless it's too big
         if ($error['code'] != 413) {
             $str .= $this->body;
         }
         if (!Z_ENV_TESTING_SITE) {
             file_put_contents(Z_CONFIG::$API_ERROR_PATH . $id, $str);
         }
         error_log($str);
     }
     if ($error['code'] != '500') {
         $errFunc = "e" . $error['code'];
         $this->{$errFunc}($error['message']);
     }
     // On testing site, display unexpected error messages
     if (Z_ENV_TESTING_SITE) {
         $this->e500($str);
     }
     $this->e500();
 }