本文整理汇总了PHP中Error::exception方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::exception方法的具体用法?PHP Error::exception怎么用?PHP Error::exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::exception方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateResponse
/**
* @param $response
* @param $expectProperty
* @return mixed
* @throws \ErrorException
*/
protected function validateResponse($response, $expectProperty)
{
if (!is_object($response) || !property_exists($response, $expectProperty)) {
return Error::exception('Authorization error');
}
return $response->{$expectProperty};
}
示例2: sort
/**
* Sorting collection by key
*
* @param string $key - element key
* @param string $direction - sorting direction (SQL style)
* @return Collection <\VCAPI\Common\Collection>
*/
public function sort($key, $direction = 'ASC')
{
$keys = array();
foreach ($this->collection as $item) {
if (is_array($item)) {
if (!isset($item[$key])) {
continue;
}
$keys[] = $item[$key];
} elseif (is_object($item)) {
if (!property_exists($item, $key)) {
continue;
}
$keys[] = $item->{$key};
}
}
if (empty($keys)) {
Error::exception('No valid data to sort');
return $this->collection;
}
$sorted = $this->collection;
$direction = $direction == 'DESC' ? SORT_DESC : SORT_ASC;
array_multisort($keys, $direction, $sorted);
return $sorted;
}
示例3: __toString
/**
* Return the view's HTML
*
* @return string
*/
public function __toString()
{
try {
ob_start();
extract((array) $this);
require SP . "View/" . $this->__view . EXT;
return ob_get_clean();
} catch (\Exception $e) {
Error::exception($e);
return '';
}
}
示例4: set_exception_handler
| may be used by the developer.
|
*/
require 'core.php';
/*
|--------------------------------------------------------------------------
| Setup Error & Exception Handling
|--------------------------------------------------------------------------
|
| Next we'll register custom handlers for all errors and exceptions so we
| can display a clean error message for all errors, as well as do any
| custom error logging that may be setup by the developer.
|
*/
set_exception_handler(function ($e) {
Error::exception($e);
});
set_error_handler(function ($code, $error, $file, $line) {
Error::native($code, $error, $file, $line);
});
register_shutdown_function(function () {
Error::shutdown();
});
/*
|--------------------------------------------------------------------------
| Report All Errors
|--------------------------------------------------------------------------
|
| By setting error reporting to -1, we essentially force PHP to report
| every error, and this is guranteed to show every error on future
| releases of PHP. This allows everything to be fixed early!
示例5: __toString
/**
* alias for render()
*
* @return string
*/
public function __toString()
{
try {
return $this->render();
} catch (\Exception $e) {
Error::exception($e);
return '';
}
}
示例6: fatal
public static function fatal()
{
if ($e = error_get_last()) {
Error::exception(new \ErrorException($e['message'], $e['type'], 0, $e['file'], $e['line']));
}
}
示例7: __toString
/**
* Return an HTML pagination string
*
* @return string
*/
public function __toString()
{
try {
// Start and end must be valid integers
$start = $this->current - $this->links > 0 ? $this->current - $this->links : 1;
$end = $this->current + $this->links < $this->total ? $this->current + $this->links : $this->total;
$html = $this->previous();
for ($i = $start; $i <= $end; ++$i) {
// Current link is "active"
$attributes = $this->current == $i ? array('class' => 'active') : array();
// Wrap the link in a list item
$html .= HTML::tag('li', HTML::link($this->url($i), $i), $attributes);
}
$html .= $this->next();
return HTML::tag('div', "<ul>\n" . $html . "</ul>\n", $this->attributes);
} catch (\Exception $e) {
Error::exception($e);
return '';
}
}
示例8: __toString
/**
* Return the current HTML form as a string
*/
public function __toString()
{
try {
if ($this->field) {
return $this->render_field();
}
if (!$this->fields) {
return '';
}
$output = '';
foreach ($this->fields as $field) {
$output .= $field;
}
return $output;
} catch (\Exception $e) {
Error::exception($e);
return '';
}
}
示例9: __construct
/**
* Inject logging logic
* @see Exception
*/
public function __construct($message = '', $code = 0, Exception $previous = null)
{
parent::__construct((string) $message, (int) $code, $previous);
Error::exception($this);
}