Jump to content
php.lv forumi
Sign in to follow this  
php newbie

Kohana error handling

Recommended Posts

taisu pēc tutoriala fiendly error pages: http://kohanaframework.org/3.2/guide/kohana/tutorials/error-pages

extendoju Kohana_Exception klasi nokopejot kodu no tutoriala. Tur ir viena metode handle.
 

testēju ar 2 kļūdam: Kohana_Exception un Kohana_HTTP_Exception (404).
 


1. Tā metode vispār netiek izsaukta kad izmet tas kļūdas
2. Kad izmet  Kohana_Exception, tiek izsaukts _handle 

3. Kad izmet Kohana_HTTP_Exception netiek izsaukts ne handle, ne _handle.

wtf? neko nesaprotu vispār.

laikam būs vienkārši error view jāparraksta...

Share this post


Link to post
Share on other sites

Ok kad sapratu ka skatos nepareizas versijas dokumentāciju tad laikam aizgāja, bet vienalga dokumentācija nav pilnīga.

Visiem HTTP exceptioniep pārrakstam application\classes\HTTP\Exception.php

<?php defined('SYSPATH') OR die('No direct script access.');

class HTTP_Exception extends Kohana_HTTP_Exception {
 
    public function get_response()
    {
        // Lets log the Exception, Just in case it's important!
        Kohana_Exception::log($this);
 
        if (Kohana::$environment >= Kohana::DEVELOPMENT)
        {
            // Show the normal Kohana error page.
            return parent::get_response();
        }
        else
        {
            $view = View::factory('error/http');
 
            $response = Response::factory()
                ->status($this->getCode())
                ->body($view->render());
 
            return $response;
        }
    }
}

 

Visiem parējiem exceptioniem application\classes\Kohana\Exception.php:
 

 

Vai nu visvienkāršakais variants pārrakstīt application\views\kohana\error.php

 

Edited by php newbie

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...