当前位置: 首页>>代码示例>>PHP>>正文


PHP Error::getCode方法代码示例

本文整理汇总了PHP中Error::getCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::getCode方法的具体用法?PHP Error::getCode怎么用?PHP Error::getCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Error的用法示例。


在下文中一共展示了Error::getCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getErrorCode

 /**
  * @return int|null
  */
 public function getErrorCode()
 {
     if ($this->error instanceof Error) {
         return $this->error->getCode();
     }
     return null;
 }
开发者ID:igaponov,项目名称:jsonrpc,代码行数:10,代码来源:Response.php

示例2: testGetAttributes

 public function testGetAttributes()
 {
     $this->assertEquals('error_type', $this->error->getType());
     $this->assertEquals('error_file', $this->error->getFile());
     $this->assertEquals('error_line', $this->error->getLine());
     $this->assertEquals('error_char', $this->error->getChar());
     $this->assertEquals('error_code', $this->error->getCode());
 }
开发者ID:neeckeloo,项目名称:ClosureCompilerPHP,代码行数:8,代码来源:ErrorTest.php

示例3: __construct

 /**
  * Wraps the passed Error class
  *
  * @param Error $error the Error object
  */
 public function __construct($error)
 {
     $this->_error = $error;
     $message = $error->getMessage();
     $code = $error->getCode();
     parent::__construct(sprintf('(%s) - %s', get_class($error), $message), $code);
 }
开发者ID:rederlo,项目名称:cakephp,代码行数:12,代码来源:PHP7ErrorException.php

示例4: testBasic

 public function testBasic()
 {
     $error = new Error('error', 1);
     $this->assertSame('error', (string) $error);
     $this->assertSame('error', $error->getMessage());
     $this->assertSame(1, $error->getCode());
 }
开发者ID:messyOne,项目名称:Loo-Framework,代码行数:7,代码来源:ErrorTest.php

示例5: error

 /**
  * Set error response
  * @param \Sonic\Controller\Error|integer|string $message Error message object, error code or message string
  * @param integer $code Error code, only used if message is a string
  * @param integer $httpCode HTTP status code
  * @return FALSE
  */
 protected function error($message = 'invalid request', $code = 0, $httpCode = 0)
 {
     if (is_numeric($message)) {
         $error = new Error($message);
         $code = $error->getCode();
         $message = $error->getMessage();
     } else {
         if ($message instanceof Error) {
             $code = $message->getCode();
             $message = $message->getMessage();
         }
     }
     $this->view->response = array('success' => 0, 'error_code' => $code, 'error_description' => $message);
     if ($httpCode) {
         $this->httpStatus($httpCode);
     }
     return FALSE;
 }
开发者ID:andyburton,项目名称:sonic-framework,代码行数:25,代码来源:JSON.php

示例6: handleException

/**
 * @param Exception | Error $e
 */
function handleException($e)
{
    $request = \OC::$server->getRequest();
    // in case the request content type is text/xml - we assume it's a WebDAV request
    $isXmlContentType = strpos($request->getHeader('Content-Type'), 'text/xml');
    if ($isXmlContentType === 0) {
        // fire up a simple server to properly process the exception
        $server = new Server();
        if (!$e instanceof RemoteException) {
            // we shall not log on RemoteException
            $server->addPlugin(new ExceptionLoggerPlugin('webdav', \OC::$server->getLogger()));
        }
        $server->on('beforeMethod', function () use($e) {
            if ($e instanceof RemoteException) {
                switch ($e->getCode()) {
                    case OC_Response::STATUS_SERVICE_UNAVAILABLE:
                        throw new ServiceUnavailable($e->getMessage());
                    case OC_Response::STATUS_NOT_FOUND:
                        throw new \Sabre\DAV\Exception\NotFound($e->getMessage());
                }
            }
            $class = get_class($e);
            $msg = $e->getMessage();
            throw new ServiceUnavailable("{$class}: {$msg}");
        });
        $server->exec();
    } else {
        $statusCode = OC_Response::STATUS_INTERNAL_SERVER_ERROR;
        if ($e instanceof \OC\ServiceUnavailableException) {
            $statusCode = OC_Response::STATUS_SERVICE_UNAVAILABLE;
        }
        if ($e instanceof RemoteException) {
            // we shall not log on RemoteException
            OC_Response::setStatus($e->getCode());
            OC_Template::printErrorPage($e->getMessage());
        } else {
            \OC::$server->getLogger()->logException($e, ['app' => 'remote']);
            OC_Response::setStatus($statusCode);
            OC_Template::printExceptionErrorPage($e);
        }
    }
}
开发者ID:GitHubUser4234,项目名称:core,代码行数:45,代码来源:remote.php

示例7: uploadData


//.........这里部分代码省略.........
                 $data[$fileID] = array_merge($props, array("status" => "inprogress", "hash" => $hash, "id" => $fileID, "files" => array()));
                 if (FileInputUtility::instance()->checkFile($this->CID, $hash)) {
                     $data[$fileID] = self::merge($data[$fileID], $this->getFromCache($data[$fileID]["hash"]));
                     if ($props["restored"] == "Y") {
                         $data[$fileID]["status"] = "inprogress";
                     }
                 }
             }
         }
         /*@var $files array*/
         $files = $this->getUploadedFiles($data);
         $logData = $this->log->getValues();
         $packData = $this->packLog->getValues();
         foreach ($data as $fileID => $file) {
             if (!$this->checkTime()) {
                 break;
             }
             $result = new Status($file["status"]);
             if ($result->getStatus() == "inprogress") {
                 unset($file["restored"]);
                 unset($file["executed"]);
                 if (array_key_exists($fileID, $files)) {
                     FileInputUtility::instance()->registerFile($this->CID, $file["hash"]);
                     foreach ($files[$fileID] as $f) {
                         $res = $this->checkFile($f, $file);
                         if ($res instanceof Error) {
                             $result = $res;
                             break;
                         }
                     }
                 }
                 if ($result->getStatus() == "inprogress") {
                     $result = $this->saveFile($file);
                 }
             }
             if (array_key_exists("restored", $file) && array_key_exists("executed", $file) && array_key_exists("~status", $file)) {
                 unset($file["restored"]);
                 unset($file["executed"]);
                 $result = new Status($file["~status"]);
             }
             $file["~status"] = $result->getStatus();
             if ($result->getStatus() == "uploaded" && $this->getPost("type") != "brief" && !array_key_exists("executed", $file)) {
                 $packData1 = $packData;
                 $logData1 = $logData;
                 $file["executed"] = "Y";
                 foreach (GetModuleEvents(self::EVENT_NAME, "onFileIsUploaded", true) as $arEvent) {
                     $error = "";
                     if (!ExecuteModuleEventEx($arEvent, array($file["hash"], &$file, &$packData, &$logData, &$error))) {
                         $result = new Error("BXU350.1", $error);
                         $file["executed"] = "error";
                         break;
                     }
                 }
                 if ($logData1 != $logData) {
                     $this->log->setValues($logData);
                 }
                 if ($packData1 != $packData) {
                     $this->packLog->setValues($packData);
                 }
             }
             $file["status"] = $result->getStatus();
             $this->setIntoCache($file["hash"], $file);
             // it is a compatibility
             $log = array("status" => $file["status"], "hash" => $file["hash"]);
             if ($result instanceof Error) {
                 $log += array("error" => $result->getMessage(), "errorCode" => $result->getCode());
                 if (empty($log["error"])) {
                     $log["error"] = "Unknown error.";
                 }
                 //					trigger_error("Uploading error: ".$file["name"]." wasn't uploaded: ".$log["error"]." [".$log["errorCode"]."]", E_USER_WARNING);
             }
             $this->files[$fileID] = $log + array("file" => $file);
             if ($file["status"] == "uploaded" || $file["status"] == "error") {
                 $this->packLog->setValue("files", array($file["id"] => $file["status"]));
             }
         }
         $declaredFiles = (int) $this->packLog->getValue("filesCount");
         if ($declaredFiles > 0 && $declaredFiles == count($this->packLog->getValue("files"))) {
             $status = new Status("done");
             if ($this->getPost("type") !== "brief") {
                 foreach (GetModuleEvents(self::EVENT_NAME, "onPackageIsFinished", true) as $arEvent) {
                     if (ExecuteModuleEventEx($arEvent, array($packData, $logData, $post, $this->files)) === false) {
                         $status = new Error("BXU350.1", $error);
                         break;
                     }
                 }
             }
         } else {
             $status = new Status("inprogress");
         }
         if ($this->getPost("type") == "brief" || $status->getStatus() == "inprogress") {
             $this->log->setValues($logData);
             $this->packLog->setValues($packData);
         } else {
             $this->packLog->unlink();
         }
     }
     $this->status = $status->getStatus();
     return $status;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:101,代码来源:uploader.php

示例8: testGetCode

 public function testGetCode()
 {
     $this->assertEquals(101, $this->error->getCode());
 }
开发者ID:phprest,项目名称:phprest,代码行数:4,代码来源:ErrorTest.php

示例9: testGetCodeMessageSql

 /**
  * Message as two immutable members code and message that can only be
  * set in the constructor
  *
  * @return null
  */
 public function testGetCodeMessageSql()
 {
     $this->assertEquals($this->errCode, $this->error->getCode());
     $this->assertEquals($this->errText, $this->error->getMessage());
     $this->assertEquals($this->sqlState, $this->error->getSqlState());
 }
开发者ID:kevinlondon,项目名称:appfuel,代码行数:12,代码来源:DbErrorTest.php

示例10: testGetCode

 public function testGetCode()
 {
     $error = new Error(42, 'Unknown error');
     $this->assertEquals(42, $error->getCode());
 }
开发者ID:youhey,项目名称:msgpackRpc,代码行数:5,代码来源:ErrorTest.php

示例11: testGetters

 public function testGetters()
 {
     $error = new Error(123, 'foo');
     $this->assertEquals(123, $error->getCode());
     $this->assertEquals('foo', $error->getMessage());
 }
开发者ID:jiangxilong,项目名称:google-apis-php-clients,代码行数:6,代码来源:ErrorTest.php

示例12: handleProductionError

 /**
  * Handles a unexpected error in production mode.
  *
  * @param \Es\System\SystemEvent $systemEvent The system event
  * @param \Exception|\Error      $exception   The exception or the error
  */
 public function handleProductionError(SystemEvent $systemEvent, $exception)
 {
     $details = ['details' => 'The resource is temporary unavailable'];
     $result = json_encode($details);
     $body = Stream::make($result);
     $status = 503;
     if ($exception instanceof ExceptionInterface && $exception->getCode()) {
         $status = $exception->getCode();
     }
     $response = new Response($status, $body, ['Content-Type' => 'application/problem+json']);
     $this->processResponse($response, $systemEvent);
 }
开发者ID:easy-system,项目名称:es-error,代码行数:18,代码来源:JsonErrorStrategy.php

示例13: handleProductionError

 /**
  * Handles a unexpected error in production mode.
  *
  * @param \Es\System\SystemEvent $systemEvent The system event
  * @param \Exception|\Error      $exception   The exception or the error
  */
 public function handleProductionError(SystemEvent $systemEvent, $exception)
 {
     $renderer = $this->getRenderer();
     $result = $renderer->render('error/production');
     $body = Stream::make($result);
     $status = 503;
     if ($exception instanceof ExceptionInterface && $exception->getCode()) {
         $status = $exception->getCode();
     }
     $response = new Response($status, $body, ['Content-Type' => 'text/html']);
     $this->processResponse($response, $systemEvent);
 }
开发者ID:easy-system,项目名称:es-error,代码行数:18,代码来源:HtmlErrorStrategy.php

示例14: newMessage

 /**
  * New exception.
  *
  * @param Exception $exception        	
  * @param boolean $printError
  *        	show error or not
  * @param boolean $clear
  *        	clear the errorlog
  * @param string $errorFile
  *        	file to save to
  */
 public static function newMessage(\Error $exception)
 {
     $message = $exception->getMessage();
     $code = $exception->getCode();
     $file = $exception->getFile();
     $line = $exception->getLine();
     $trace = $exception->getTraceAsString();
     $trace = str_replace(DB_PASS, '********', $trace);
     $date = date('M d, Y G:iA');
     $logMessage = "<h3>Exception information:</h3>\n\n           <p><strong>Date:</strong> {$date}</p>\n\n           <p><strong>Message:</strong> {$message}</p>\n\n           <p><strong>Code:</strong> {$code}</p>\n\n           <p><strong>File:</strong> {$file}</p>\n\n           <p><strong>Line:</strong> {$line}</p>\n\n           <h3>Stack trace:</h3>\n\n           <pre>{$trace}</pre>\n\n           <hr />\n";
     $errorFile = self::getCurrentErrorLog();
     if (is_file($errorFile) === false) {
         file_put_contents($errorFile, '');
     }
     if (self::$clear) {
         $f = fopen($errorFile, "r+");
         if ($f !== false) {
             ftruncate($f, 0);
             fclose($f);
         }
         $content = null;
     } else {
         $content = file_get_contents($errorFile);
     }
     file_put_contents($errorFile, $logMessage . $content);
     if (self::$printError == true) {
         echo $logMessage;
         exit;
     }
 }
开发者ID:krishnasrikanth,项目名称:smvc-php7,代码行数:41,代码来源:Logger.php

示例15: FormatErrorMessage

 protected function FormatErrorMessage(Error $Error)
 {
     return $Error->getTimestamp() . ' [' . $Error->getCode() . '] "' . $Error->getMessage() . '" in file: ' . $Error->getFilepath() . ', line: ' . $Error->getLine() . PHP_EOL . $Error->getRequest();
 }
开发者ID:jamm,项目名称:errorhandler,代码行数:4,代码来源:ErrorHandler.php


注:本文中的Error::getCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。