/** * Constructor. * @param integer $status CURL status code, such as 404, 500, etc. * @param string $message error message * @param ACurlResponse $response The CURL response * @param integer $code error code */ public function __construct($status, $message = null, $response = null, $code = 0) { $this->statusCode = $status; $this->response = $response; $message .= ":\n" . $response->data; parent::__construct($message, $code); }
public function __construct($file, $line, $message) { parent::__construct($message); // Replace the information from the throw // of this exception with the information // from the failed assertion. $this->file = $file; $this->line = $line; }
/** * @param string|array $message simple string or array( "message with {param}", array("param" => "value") ) to use in Yii::t * @param int $code * @param Exception $previous */ public function __construct($message = "", $code = 0, Exception $previous = null) { $params = array(); if (is_array($message)) { $params = $message[1]; $message = $message[0]; } $message = Yii::t('core', $message, $params); parent::__construct($message, $code, $previous); }
/** * recursively delete a directory / file * @param $str * @return bool * @throws CException */ public static function delete($str) { if (!is_string($str)) { $exception = new CException("Core_Directory:delete error"); $exception->set("dir", $str); //$exception->set("service", $_REQUEST["service"]); //$exception->set("request", $_REQUEST["request"]); throw $exception; } if (is_file($str)) { return @unlink($str); } elseif (is_dir($str)) { $scan = glob(rtrim($str, '/') . '/*'); foreach ($scan as $index => $path) { self::delete($path); } return @rmdir($str); } return true; }
public function __construct($message, $code) { if (is_array($message)) { $result = ''; foreach ($message as $m) { $result .= implode(';', $m); } $message = $result; } parent::__construct($message); $this->code = $code; }
/** * Render view template * @param string $template php file in views/(without .php extension) * @param array $_____params render variable * @param null $self use to pass $this ($self represent $this in template) * @return string * @throws CException */ public static function render($template, $_____params = array(), &$self = null) { if (file_exists($template)) { $f = $template; } else { $f = "views/{$template}.php"; } if (file_exists($f)) { extract($_____params, EXTR_SKIP); ob_start(); include $f; $return = ob_get_contents(); ob_end_clean(); return $return; } else { $exception = new CException("View : template {$template} not found"); $exception->set("template", $f); $exception->set("service", $_REQUEST->service); $exception->set("request", $_REQUEST->request); throw $exception; } }
/** * Initialize the exception, saving the driver that was passed * * @param string $message * @param integer $code * @param GeoCode_Driver $driver * @return GeoCode_Exception */ public function __construct($message = '', $code = 0, GeoCode_Driver $driver = null) { $this->driver = $driver; parent::__construct($message, $code); }
function __construct($message = 'Not Found') { parent::__construct($message, 404); }
/** * @param $message * @param int $code * * @return Exception */ public function __construct($message, $code = 0) { Craft::log($message, LogLevel::Error); parent::__construct($message, $code); }
public function __construct($responseCode, $message) { $this->_responseCode = $responseCode; parent::__construct($message); }
/** * Constructor. * @param integer $status HTTP status code, such as 404, 500, etc. * @param string $message error message * @param integer $code error code */ public function __construct($status, $message = null, $code = 0) { $this->statusCode = $status; parent::__construct($message, $code); }
/** * 引入文件 仅供自身使用 */ public static function import($className, $path) { //文件不存在 if (!file_exists($path)) { trigger_error('[类寻址错误]路由映射中类[' . $className . ']所设置的文件路径不存在:' . CException::filterFileTruePath($path), E_USER_ERROR); } //引入文件 $importStatus = (include_once $path); if (!$importStatus) { throw new CClassNotFoundException($className); } return $importStatus; }
/** * 请求结束 */ public static function webShutdown() { //传递引起脚本中断的致命错误 $lastError = error_get_last(); if (!empty($lastError) && in_array($lastError['type'], array(E_USER_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_ERROR))) { CException::getTopErrors($lastError['type'], $lastError['message'], $lastError['file'], $lastError['line']); } //脚本因错误而中断 if (true == CException::hasFatalErrors()) { //最后发生的错误 $lastError = error_get_last(); //设置503请求头 CResponse::getInstance()->setHttpCode(503, false); } //触发执行结束钩子函数 CHooks::callHooks(HOOKS_SYSTEM_SHUTDOWN, CException::$errorList); //是否使用CMyFrame 默认错误呈现 if (true == CException::getErrorShow()) { //使用CMyFrame 默认进行错误呈现 CException::showErrorsView(); } }
/** * 对错误进行分解 */ private static function _categoryError() { //分级 $categoryErrors = array(); self::$errorList = array_reverse(self::$errorList); foreach (self::$errorList as $val) { $tips = 'ErrorException'; switch ($val[0]) { case 1: $lv = '致命错误'; $tips = 'Fatal Error'; break; case 2: $lv = '运行警告'; $tips = 'Warning'; break; case 4: $lv = '解析错误'; break; case 8: $lv = '运行提示'; $tips = 'Notice'; break; case 16: $lv = 'PHP内核错误'; $tips = 'Core Error'; break; case 32: $lv = 'PHP内核警告'; $tips = 'Core Warning'; break; case 64: $lv = 'Zend致命错误'; break; case 128: $lv = 'Zend运行警告'; $tips = 'Zend Warning'; break; case 256: $lv = '自定义错误'; $tips = 'USER Error'; break; case 512: $lv = '自定义警告'; $tips = 'USER Warning'; break; case 1024: $lv = '自定义通知'; $tips = 'USER Notice'; break; case 2048: $lv = '代码通知'; return false; case 10000: $lv = '安全警告'; return false; default: $lv = '致命错误'; } //错误代码 $errorText = self::getErrorText($val[2], $val[3]); $categoryErrors[] = array('code' => $val[0], 'content' => $val[1], 'file' => self::filterFileTruePath($val[2]), 'line' => $val[3], 'level' => $lv, 't_tips' => $tips, 'detail' => $errorText); } //返回分级后的错误 return $categoryErrors; }
/** * @param CException $e * @return bool|null */ public static function exceptionHandler(CException $e) { self::$trace = $e->getTrace(); self::errorHandler([5040, 'Exception: ' . $e->getMessage(), $e->getFile(), $e->getLine()]); return mfe::stopEngine(); }
public function __construct($url) { parent::__construct(); $this->url = $url; }
public function __construct($message, $code = -32603, $data = null) { $this->data = $data; parent::__construct($message, $code); }
public function __construct($return, $message = null, $code = 0, $previous = null) { parent::__construct($message, $code, $previous); $this->return = $return; }
/** * @param mixed $message error message or a CModel object that has errors * @param int $code Use different codes for different errors */ public function __construct($message, $code = 0) { if ($code === 0) { $code = self::ERR_BUSINESS_EXCEPTION; } if ($message instanceof CModel) { $message = CHtml::errorSummary($message, ''); } // we don't use the code from PHP's Exception object parent::__construct($message, CPropertyValue::ensureInteger($code)); $this->errorCode = $code; $this->message = $message; }
public function __construct($message, $code = 0, $errorInfo = null) { $this->errorInfo = $errorInfo; parent::__construct($message, $code); }
/** * Sass Exception. * @param string Exception message * @param array parameters to be applied to the message using <code>strtr</code>. * @param object object with source code and meta data */ public function __construct($message, $params, $object) { parent::__construct(Yii::t('sass', $message, $params) . (is_object($object) ? ": {$object->filename}::{$object->line}\nSource: {$object->source}" : '')); }
/** * Конструктор * @param string $message Сообщение об ошибке * @param integer $code error code */ public function __construct($message = null, $code = 0) { parent::__construct($message, $code); }
/** * Execute $r method of a class or instance $Obj * @param string|object $Obj Class name or an instance of the class * @param string $r Method name * @param array $params Method parameters * @return mixed * @throws CException * @throws null */ public static function execTask($Obj, $r, array $params = array()) { // Si nom de classe renseigné if (!is_object($Obj)) { $s = $Obj; try { // static class if (self::isStatic($s, $r)) { $Obj = $s; } else { $Obj = new $s(); } } catch (CException $exception) { $exception = new CException("service {$s}:{$r} not found"); $exception->set("service", $s); $exception->set("request", $r); throw $exception; } } else { // Si objet passé en paramètres $s = get_class($Obj); } if (method_exists($s, $r) && is_callable(array($s, $r))) { // TODO à corriger if (!is_array($params)) { $params = array($params); } // Limit parameter to method definition (pour securité ?) $Met = new \ReflectionMethod($s, $r); $Param = $Met->getParameters(); if (empty($Param)) { $Param = array(); } $params = array_slice($params, 0, count($Param)); $res = call_user_func_array(array($Obj, $r), $params); // Log les appels des services // TODO disable for prod $logParams = array(); foreach ($params as $p) { if (is_scalar($p)) { $l = strip_tags($p); if (strlen($l) > 20) { $l = substr($l, 0, 20) . "..."; } $logParams[] = $l; } elseif (is_array($p)) { $logParams[] = "Array"; } elseif (is_object($p)) { $logParams[] = "Object[" . get_class($p) . "]"; } } FirePHP::fbLog("info", "{$s}/{$r}(" . implode(", ", $logParams) . ")"); return $res; } else { $exception = null; if (!method_exists($s, $r)) { $exception = new CException("service {$s}:{$r} not found"); } elseif (!is_callable(array($s, $r))) { $exception = new CException("serviceNotCallable"); } $exception->set("service", $s); $exception->set("request", $r); throw $exception; } }