Bug Report #4695

Kohana_Exception handlers

Added by Eugene Alright 4 months ago. Updated 29 days ago.

Status:Assigned Start date:02/03/2013
Priority:Normal Due date:
Assignee:Lorenzo Pisani % Done:

0%

Category:Core
Target version:3.3.1
Resolution: Points:1

Description

There is definitely something wrong with this piece of code (look at pic in attachments). Second handler is public, but named with underscore before name, like it says it is a protected one. And it's getting even more confusing when I try to override the handler. Which one should I use?

2731be45e89c412572599b2dc4c558da10a37cfd.png (31.7 kB) Eugene Alright, 02/03/2013 06:03 pm

kohana-exception.png (16.6 kB) Eugene Alright, 02/05/2013 07:10 pm

History

Updated by Jeremy Bush 4 months ago

There's nothing wrong here. You should read the docs on implementing custom http exceptions: http://kohanaframework.org/3.3/guide/kohana/tutorials/error-pages

Updated by Eugene Alright 4 months ago

Well, I've read the docs earlier. But I thought that with implementing get_response method in the main HTTP_Exception class, Kohana will convert all uncatched exceptions into HTTP_Exception, so it's will show a response that I want ("Oops" page).
But it seems it doesn't work this way. Instead, I have to do some work in Kohana_Exception class, which is a parent for all other classes. You can see in attachments what I did there. What am I doing wrong?

Updated by David Chan 3 months ago

I am having a similar problem.

I overrode HTTP_Exception::get_response to display a custom error page, and I use HTTP_Exception_XXX throughout my code for user errors (as opposed to developer errors)

However I noticed that HTTP_Exception has a special catch block in Kohana/Request/Client.php which does not use Kohana_Exception::handler()

Unfortunately when I throw exceptions from Route::Filter methods I am not yet within the scope of this special catch, and I do not see my expected custom error page.

This is important because my project is a RESTful API and I must return the proper HTTP error code 400, etc

but when I return false instead of throwing an error in my Route::Filters I always get a 404.

Updated by David Chan 3 months ago

I have a patch which addresses my issue.

[[https://github.com/kohana/core/pull/331]]

Updated by David Chan 3 months ago

i added a new issue #4697 since my issue is not as similar as i first thought

Updated by Lorenzo Pisani 29 days ago

  • Status changed from New to Assigned
  • Assignee set to Lorenzo Pisani
  • Target version set to 3.3.1

Updated by Jeremy Bush 29 days ago

To me it sounds like you are using routes like controllers. I'm not sure why you would want to throw an HTTP exception inside a route filter.

Also available in: Atom PDF