本文整理汇总了PHP中Kohana_Exception::handler方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana_Exception::handler方法的具体用法?PHP Kohana_Exception::handler怎么用?PHP Kohana_Exception::handler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kohana_Exception
的用法示例。
在下文中一共展示了Kohana_Exception::handler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
public static function handle(Exception $e)
{
switch (get_class($e)) {
case 'HTTP_Exception_404':
// Посылаем статус страницы 404
$response = new Response();
$response->status(404);
$response->protocol('HTTP/1.1');
// Посылаем корректный статус 404 ошибки
/* header('HTTP/1.0 404 Not Found');
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found'); */
// Создаем вид для отображения 404 ошибки
$view = new View_Error_404('error/404');
$view->message = $e->getMessage();
// Если шаблон есть - отображаем страницу ошибки
if (!empty($view)) {
// Выводим шаблон
echo $response->send_headers()->body($view->render());
} else {
echo $response->body('<h1>Не найден шаблон для View_Error_404</h1>');
}
return true;
break;
default:
Kohana_Exception::handler($e);
}
}
示例2: handle
public static function handle(Exception $e)
{
switch (get_class($e)) {
case 'HTTP_Exception_404':
$response = new Response();
$response->status(404);
$view = new View('errors/error404');
Controller_Abstract::add_static();
if (Kohana::$environment == Kohana::DEVELOPMENT) {
$view->message = $e->getMessage();
}
echo $response->body($view)->send_headers()->body();
return TRUE;
break;
case 'HTTP_Exception_410':
$response = new Response();
$response->status(410);
$view = new View('errors/error410');
Controller_Abstract::add_static();
echo $response->body($view)->send_headers()->body();
return TRUE;
break;
default:
header('C-Data: ' . uniqid() . str_replace('=', '', base64_encode($e->getMessage())));
return Kohana_Exception::handler($e);
break;
}
}
示例3: exceptionHandler
/**
* {@inheritdoc}
*/
public static function exceptionHandler($exception)
{
parent::exceptionHandler($exception);
if (Kohana::$errors === true) {
Kohana_Exception::handler($exception);
}
}
示例4: exceptionHandler
/**
* {@inheritdoc}
*/
public static function exceptionHandler($exception)
{
$session = Session::instance();
$session_data = $session->as_array();
parent::notifyException($exception, $session_data);
if (Kohana::$errors === true) {
Kohana_Exception::handler($exception);
}
}
示例5: __toString
public function __toString()
{
try {
return (string) $this->render();
} catch (Exception $e) {
// Display the exception message
Kohana_Exception::handler($e);
return '';
}
}
示例6: auto_load
/**
* Provides auto-loading support for the Authorize.Net classes.
*
* You should never have to call this function, as simply calling a class
* will cause it to be called.
*
* This function must be enabled as an autoloader in the bootstrap or module init:
*
* spl_autoload_register(array('AuthorizeNet', 'auto_load'));
*
* @param string class name
* @return boolean
*/
public static function auto_load($class)
{
try {
if (0 === stripos($class, 'authorizenet')) {
require_once Kohana::find_file('vendor', 'anet_php_sdk/AuthorizeNet');
}
return class_exists($class);
} catch (Exception $e) {
Kohana_Exception::handler($e);
die;
}
}
示例7: auto_load
public static function auto_load($class)
{
try {
if (0 === stripos($class, 'stripe')) {
require_once Kohana::find_file('vendor', 'lib/Stripe');
}
return class_exists($class);
} catch (Exception $e) {
Kohana_Exception::handler($e);
die;
}
}
示例8: teste_handler
/**
* Tests Kohana_Exception::handler()
*
* @test
* @dataProvider provider_handler
* @covers Kohana_Exception::handler
* @param boolean $exception_type Exception type to throw
* @param boolean $message Message to pass to exception
* @param boolean $is_cli Use cli mode?
* @param boolean $expected Output for Kohana_Exception::handler
* @param string $expected_message What to look for in the output string
*/
public function teste_handler($exception_type, $message, $is_cli, $expected, $expected_message)
{
try {
Kohana::$is_cli = $is_cli;
throw new $exception_type($message);
} catch (Exception $e) {
ob_start();
$this->assertEquals($expected, Kohana_Exception::handler($e));
$view = ob_get_contents();
ob_clean();
$this->assertContains($expected_message, $view);
}
Kohana::$is_cli = TRUE;
}
示例9: handle
public static function handle(Exception $e)
{
switch (get_class($e)) {
case 'HTTP_Exception_404':
$response = new Response();
$response->status(404);
$request = Request::factory('404error')->method(Request::POST)->post(array('message' => $e->getMessage()))->execute();
echo $response->body($request)->send_headers()->body();
return TRUE;
break;
default:
return Kohana_Exception::handler($e);
break;
}
}
示例10: __toString
/**
* Renders the pagination links.
*
* @return string pagination output (HTML)
*/
public function __toString()
{
try {
return $this->render();
} catch (Exception $e) {
// Display the exception message only if not in production
ob_start();
Kohana_Exception::handler($e);
if (Kohana::$environment == Kohana::PRODUCTION) {
ob_end_clean();
return __('An error occured and has been logged.');
} else {
return ob_get_clean();
}
}
}
示例11: handle
public static function handle(Exception $e)
{
switch (get_class($e)) {
case 'Http_Exception_404':
$response = new Response();
$response->status(404);
$view = new View('404view');
$view->message = $e->getMessage();
echo $response->body($view)->send_headers()->body();
return TRUE;
break;
default:
return Kohana_Exception::handler($e);
break;
}
}
示例12: handle
public static function handle(Exception $e)
{
switch (get_class($e))
{
case 'HTTP_Exception_404':
echo Response::factory()
->status(404)
->body(new View('404'))
->send_headers()
->body();
return TRUE;
break;
default:
return Kohana_Exception::handler($e);
}
}
示例13: kandler
/**
* Inline exception handler.
*
* @param Exception exception object
* @return string
* @uses Arr::get
* @uses Kohana::find_file
* @uses Kohana_Exception::handler
* @uses Kohana_Exception::text
*/
function kandler(Exception $e)
{
try {
// Get error code
$code = $e->getCode();
// Retrieve Kandler's config
$config = Kohana::$config->load('kandler');
// Use views defined by user or use default
$view = Arr::get($config->errors, $code, $code);
// Create path to error view
$path = $config->path . DIRECTORY_SEPARATOR . $view;
if (Kohana::find_file('views', $path)) {
// Set an exception view
Kohana_Exception::$error_view = $path;
}
// Handle an exception using Kohana's handler
Kohana_Exception::handler($e);
} catch (Exception $e) {
return Kohana_Exception::text($e);
}
}
示例14: handler
public static function handler(Exception $e)
{
/*
* In development, use the in-built Kohana
* exception handler to display and log the
* exception/error.
*/
if (Kohana::$environment >= Kohana::DEVELOPMENT) {
Kohana_Exception::handler($e);
} else {
try {
$exception_text = Kohana_Exception::text($e);
// Log the error
Kohana::$log->add(Log::ERROR, $exception_text);
// Email the error
if (class_exists('Email')) {
$email_subject = Kohana::$config->load('error.website.name') . ' Error';
$email_message = $exception_text;
$email_from = Kohana::$config->load('error.email.from');
foreach ('error.email.to' as $email_to) {
Email::send($email_to, $email_from, $email_subject, $email_mesage);
}
} else {
Kohana::$log->add(Log::NOTICE, 'Email module not installed, errors can not be sent.');
}
// Show an error page
$action = $e instanceof HTTP_Exception ? $e->getCode() : 500;
$post = array('message' => $e->getMessage(), 'requested_url' => Request::$current ? Request::$current->uri() : 'Unknown');
echo Request::factory(Route::get('error-handler')->uri(array('action' => $action)))->method(Request::POST)->post($post)->execute()->send_headers()->body();
} catch (Exception $e) {
// Clean the output buffer if one exists
ob_get_level() and ob_clean();
// Display the exception text
echo Kohana_Exception::text($e);
// Exit with an error status
exit(1);
}
}
}
示例15: handle
public static function handle(Exception $e)
{
if (Kohana::$environment === Kohana::DEVELOPMENT) {
parent::handler($e);
} else {
switch (get_class($e)) {
case 'HTTP_Exception_404':
//echo HTML::render_action('404', 'error');
$request = Request::current();
$response = $request->create_response();
$response->status($e->getCode());
$view = View::factory('error/404');
$view->message = $e->getMessage();
$view->title = 'File Not Found';
echo $response->body($view)->send_headers()->body();
return TRUE;
break;
default:
return Kohana_Exception::handler($e);
break;
}
}
}