• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Kohana_Exception类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: exceptionHandler

 /**
  * {@inheritdoc}
  */
 public static function exceptionHandler($exception)
 {
     parent::exceptionHandler($exception);
     if (Kohana::$errors === true) {
         Kohana_Exception::handler($exception);
     }
 }
开发者ID:sjungwirth,项目名称:KoBugsnag,代码行数:10,代码来源:kobugsnag.php


示例2: login

 public function login()
 {
     $form = $errors = array("user" => "", "password" => "");
     $post = new Validation($_POST);
     $post->add_rules("user", "required");
     $post->add_rules("password", "required");
     if ($valid = $post->validate()) {
         try {
             $token = G3Remote::instance()->get_access_token($post["user"], $post["password"]);
             Session::instance()->set("g3_client_access_token", $token);
             $response = G3Remote::instance()->get_resource("gallery");
             $valid = true;
             $content = $this->_get_main_view($response->resource);
         } catch (Exception $e) {
             Kohana_Log::add("error", Kohana_Exception::text($e));
             $valid = false;
         }
     }
     if (!$valid) {
         $content = new View('login.html');
         $content->form = arr::overwrite($form, $post->as_array());
         $content->errors = arr::overwrite($errors, $post->errors());
     }
     $this->auto_render = false;
     print json_encode(array("status" => $valid ? "ok" : "error", "content" => (string) $content));
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:26,代码来源:g3_client.php


示例3: action_index

 public function action_index()
 {
     // Set up custom error view
     Kohana_Exception::$error_view = 'error/data-provider';
     if ($this->request->method() != 'GET') {
         // Only GET is allowed as FrontlineSms does only GET request
         throw HTTP_Exception::factory(405, 'The :method method is not supported. Supported methods are :allowed_methods', array(':method' => $this->request->method(), ':allowed_methods' => Http_Request::GET))->allowed(Http_Request::GET);
     }
     $provider = DataProvider::factory('frontlinesms');
     // Authenticate the request
     $options = $provider->options();
     if (!isset($options['key']) or empty($options['key'])) {
         throw HTTP_Exception::factory(403, 'Key value has not been configured');
     }
     if (!$this->request->query('key') or $this->request->query('key') != $options['key']) {
         throw HTTP_Exception::factory(403, 'Incorrect or missing key');
     }
     if (!$this->request->query('m')) {
         throw HTTP_Exception::factory(403, 'Missing message');
     }
     // Remove Non-Numeric characters because that's what the DB has
     $from = preg_replace('/\\D+/', "", $this->request->post('from'));
     $message_text = $this->request->query('m');
     // If receiving an SMS Message
     if ($from and $message_text) {
         $provider->receive(Message_Type::SMS, $from, $message_text, $to);
     }
     $json = array('payload' => array('success' => TRUE, 'error' => NULL));
     // Set the correct content-type header
     $this->response->headers('Content-Type', 'application/json');
     $this->response->body(json_encode($json));
 }
开发者ID:nolanglee,项目名称:platform,代码行数:32,代码来源:Frontlinesms.php


示例4: shutdown_handler

 /**
  * Catches errors that are not caught by the error handler, such as E_PARSE.
  *
  * @uses    Kohana_Exception::handle()
  * @return  void
  */
 public static function shutdown_handler()
 {
     if (Kohana_PHP_Exception::$enabled and $error = error_get_last() and error_reporting() & $error['type']) {
         // Fake an exception for nice debugging
         Kohana_Exception::handle(new Kohana_PHP_Exception($error['type'], $error['message'], $error['file'], $error['line']));
     }
 }
开发者ID:assad2012,项目名称:gallery3-appfog,代码行数:13,代码来源:Kohana_PHP_Exception.php


示例5: get_response

 /**
  * Generate a Response for the 404 Exception.
  *
  * The user should be shown a nice 404 page.
  *
  * @return Response
  */
 public function get_response()
 {
     Kohana_Exception::log($this);
     $response = Request::factory(Route::get('default')->uri(array('controller' => 'Errors', 'action' => '404')))->execute();
     $response->status(404);
     return $response;
 }
开发者ID:woduda,项目名称:kohana-dashboard,代码行数:14,代码来源:404.php


示例6: log

 /**
  * @param Exception $e
  */
 protected static function log(Exception $e)
 {
     $logLevel = self::config('cache.log.exceptions', static::$logExceptions);
     if (FALSE !== $logLevel) {
         Kohana_Exception::log($e, $logLevel);
     }
 }
开发者ID:vspvt,项目名称:kohana-helpers,代码行数:10,代码来源:Cache.php


示例7: 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;
     }
 }
开发者ID:nergal,项目名称:2mio,代码行数:28,代码来源:handler.php


示例8: 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);
     }
 }
开发者ID:bosoy83,项目名称:progtest,代码行数:28,代码来源:exceptionhandler.php


示例9: action_index

 public function action_index()
 {
     // Set up custom error view
     Kohana_Exception::$error_view = 'error/data-provider';
     //Check if data provider is available
     $providers_available = Kohana::$config->load('features.data-providers');
     if (!$providers_available['smssync']) {
         throw HTTP_Exception::factory(403, 'The SMS Sync data source is not currently available. It can be accessed by upgrading to a higher Ushahidi tier.');
     }
     $methods_with_http_request = [Http_Request::POST, Http_Request::GET];
     if (!in_array($this->request->method(), $methods_with_http_request)) {
         // Only POST or GET is allowed
         throw HTTP_Exception::factory(405, 'The :method method is not supported. Supported methods are :allowed_methods', array(':method' => $this->request->method(), ':allowed_methods' => implode(',', $methods_with_http_request)))->allowed($methods_with_http_request);
     }
     $this->_provider = DataProvider::factory('smssync');
     $this->options = $this->_provider->options();
     // Ensure we're always returning a payload..
     // This will be overwritten later if incoming or task methods are run
     $this->_json['payload'] = ['success' => TRUE, 'error' => NULL];
     // Process incoming messages from SMSSync only if the request is POST
     if ($this->request->method() == 'POST') {
         $this->_incoming();
     }
     // Attempt Task if request is GET and task type is 'send'
     if ($this->request->method() == 'GET' and $this->request->query('task') == 'send') {
         $this->_task();
     }
     // Set the response
     $this->_set_response();
 }
开发者ID:tobiasziegler,项目名称:platform,代码行数:30,代码来源:Smssync.php


示例10: _show_themed_error_page

 /**
  * Shows a themed error page.
  * @see Kohana_Exception::handle
  */
 private static function _show_themed_error_page(Exception $e)
 {
     // Create a text version of the exception
     $error = Kohana_Exception::text($e);
     // Add this exception to the log
     Kohana_Log::add('error', $error);
     // Manually save logs after exceptions
     Kohana_Log::save();
     if (!headers_sent()) {
         if ($e instanceof Kohana_Exception) {
             $e->sendHeaders();
         } else {
             header("HTTP/1.1 500 Internal Server Error");
         }
     }
     $view = new Theme_View("page.html", "other", "error");
     if ($e instanceof Kohana_404_Exception) {
         $view->page_title = t("Dang...  Page not found!");
         $view->content = new View("error_404.html");
         $user = identity::active_user();
         $view->content->is_guest = $user && $user->guest;
         if ($view->content->is_guest) {
             $view->content->login_form = new View("login_ajax.html");
             $view->content->login_form->form = auth::get_login_form("login/auth_html");
             // Avoid anti-phishing protection by passing the url as session variable.
             Session::instance()->set("continue_url", url::current(true));
         }
     } else {
         $view->page_title = t("Dang...  Something went wrong!");
         $view->content = new View("error.html");
     }
     print $view;
 }
开发者ID:andyst,项目名称:gallery3,代码行数:37,代码来源:MY_Kohana_Exception.php


示例11: handler

 public static function handler(Exception $e)
 {
     $response = Kohana_Exception::_handler($e);
     var_dump($e);
     // Send the response to the browser
     //echo $response->send_headers()->body();
     //exit(1);
 }
开发者ID:astar3086,项目名称:studio_logistic,代码行数:8,代码来源:exception.php


示例12: __toString

 /**
  * Return the SQL query string.
  *
  * @return  string
  */
 public final function __toString()
 {
     try {
         // Return the SQL string
         return $this->compile(Database::instance());
     } catch (Exception $e) {
         return Kohana_Exception::text($e);
     }
 }
开发者ID:reznikds,项目名称:Reznik,代码行数:14,代码来源:query.php


示例13: __toString

 /**
  * Magically converts mod view object to string.
  *
  * @return  string
  */
 public function __toString()
 {
     try {
         return $this->render(false, array($this, 'wrap'));
     } catch (Exception $e) {
         Kohana_Exception::handle($e);
         return '';
     }
 }
开发者ID:anqqa,项目名称:Anqh,代码行数:14,代码来源:View_Mod.php


示例14: 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);
     }
 }
开发者ID:noahkoch,项目名称:Bughana,代码行数:12,代码来源:kobugsnag.php


示例15: get_response

 /**
  * Generates a Response for all Exceptions without a specific override
  *
  * @return Response
  */
 public function get_response()
 {
     // Log the exception
     Kohana_Exception::log($this);
     $response = Response::factory();
     $view = Swiftriver::get_base_error_view();
     $view->content = View::factory('pages/errors/404')->set('page', $this->request()->uri());
     $response->body($view->render());
     return $response;
 }
开发者ID:aliyubash23,项目名称:SwiftRiver,代码行数:15,代码来源:404.php


示例16: __construct

 /**
  * Creates a new translated exception.
  *
  *     throw new Kohana_Exception('Something went terrible wrong, :user',
  *         array(':user' => $user));
  *
  * @param   string   status message, custom content to display with error
  * @param   array    translation variables
  * @param   integer  the http status code
  * @return  void
  */
 public function __construct($message = NULL, array $variables = NULL, $code = 0)
 {
     if ($code == 0) {
         $code = $this->_code;
     }
     if (!isset(Response::$messages[$code])) {
         throw new Kohana_Exception('Unrecognized HTTP status code: :code . Only valid HTTP status codes are acceptable, see RFC 2616.', array(':code' => $code));
     }
     parent::__construct($message, $variables, $code);
 }
开发者ID:sysdevbol,项目名称:entidad,代码行数:21,代码来源:exception.php


示例17: __toString

 public function __toString()
 {
     try {
         return (string) $this->render();
     } catch (Exception $e) {
         // Display the exception message
         Kohana_Exception::handler($e);
         return '';
     }
 }
开发者ID:ariol,项目名称:adminshop,代码行数:10,代码来源:Widget.php


示例18: get_response

 public function get_response()
 {
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         return parent::get_response();
     } else {
         $response = Response::factory()->status(401)->headers('Location', URL::site('/'));
         return $response;
     }
 }
开发者ID:Kapitonova,项目名称:codex,代码行数:10,代码来源:401.php


示例19: get_response

 public function get_response()
 {
     // Lets log the Exception, Just in case it's important!
     Kohana_Exception::log($this);
     $params = array('code' => $this->getCode(), 'message' => rawurlencode($this->getMessage()), 'response' => NULL, 'errors' => $this->_errors);
     try {
         return json_encode($params);
     } catch (Exception $e) {
         return parent::get_response();
     }
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:11,代码来源:exception.php


示例20: log

 /**
  * Logs with an arbitrary level.
  *
  * @param string  $level  a PSR LogLevel constant
  * @param string $message
  * @param array  $context
  *
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     $level = $this->convert_psr_to_kohana_level($level);
     if ($exception = $this->get_exception_from_context($context)) {
         $message .= \PHP_EOL . \Kohana_Exception::text($exception);
     } elseif ($message instanceof \Exception) {
         $context['exception'] = $message;
         $message = \Kohana_Exception::text($message);
     }
     $this->log->add($level, $message, array(), $context);
 }
开发者ID:ingenerator,项目名称:kohana-logger,代码行数:20,代码来源:KohanaLogger.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Kohana_Log类代码示例发布时间:2022-05-23
下一篇:
PHP Kohana类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap