In Kohana, can you trigger a 404 error?

后端 未结 3 2016
陌清茗
陌清茗 2021-02-14 10:10

I have a controller called articles, which creates the articles model which gets the relevant data from the database.

I want to, if the method I call return

相关标签:
3条回答
  • 2021-02-14 10:40

    Kohana Docs tells you way to do it:

    throw HTTP_Exception::factory(404, 'File not found!');
    
    0 讨论(0)
  • 2021-02-14 11:01

    Kohana / General / Error-handling / Kohana_404_Exception

    /**
     * @param  string  URL of page
     * @param  string  custom error template
     */
    throw new Kohana_404_Exception([string $page [, string $template]]);
    
    0 讨论(0)
  • 2021-02-14 11:04

    This works for me:

    Event::run('system.404');
    

    What version of Kohana are you using?

    0 讨论(0)
提交回复
热议问题