本文整理汇总了PHP中Exception::text方法的典型用法代码示例。如果您正苦于以下问题:PHP Exception::text方法的具体用法?PHP Exception::text怎么用?PHP Exception::text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Exception
的用法示例。
在下文中一共展示了Exception::text方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert_to_error
/**
* Converts an exception into a PHP error.
*
* This method can be used to convert exceptions inside of methods like `__toString()`
* to PHP errors because exceptions cannot be thrown inside of them.
* @param \Exception $exception the exception to convert to a PHP error.
*/
public static function convert_to_error($exception)
{
trigger_error(Exception::text($exception), E_USER_ERROR);
}
示例2: __toString
/**
* Magic object-to-string method.
*
* echo $exception;
*
* @uses Exception::text
* @return string
*/
public function __toString()
{
return Exception::text($this);
}
示例3: __toString
/**
* Render the current image.
*
* echo $image;
*
* [!!] The output of this function is binary and must be rendered with the
* appropriate Content-Type header or it will not be displayed correctly!
*
* @return string
*/
public function __toString()
{
try {
// Render the current image
return $this->render();
} catch (Exception $e) {
if (is_object(Kohana::$log)) {
// Get the text of the exception
$error = Exception::text($e);
// Add this exception to the log
Kohana::$log->add(Log::ERROR, $error);
}
// Showing any kind of error will be "inside" image data
return '';
}
}