Jump to content

Class 'Wire404Exception' not found

Recommended Posts

 I'm using "throw new Wire404Exception();"  in my template, it worked fine. After Migrating to an other server and Upgrading to PW 3.0.62 I got an Error "Class 'Wire404Exception' not found" . I spent the day yesterday unsuccessfully to understand the reason. Is there any reason, why PW can't find this class? The Exceptions.php in wire/core exists.


I beg your pardon, if this topic should be discussed here yet - the search items 'Wire404Exception' and 'not found'  leed to many other results not related to the class itself. :-)

Share this post

Link to post
Share on other sites

Howdy @Thorsten, and welcome to the forum!

The only thing I can think of in my limited experience is since it is a different server maybe the rewrite in htaccess is not correct. If throwing this exception worked on a previous server, and now does not work on a new server, that leads me to believe there is something out of whack with the new server.

Others more knowledgeable will be along shortly to help further.

Again, welcome to the fold.

  • Like 1

Share this post

Link to post
Share on other sites

Have you declared namespaces in your templates files? 

  • Like 2

Share this post

Link to post
Share on other sites

Thank you for the answers.


@rick The .htacess has the same configuration, I checked this before.


@Zeka No, i didn 't. I just transfered the template files. I didn 't know that could be neccessary. I'll try it (need to check how it should be done).

Share this post

Link to post
Share on other sites

Thank you very much, @Zeka, this was the solution indeed. Now I get the Error 404 as intended.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Moritz Both
      For our PW project we use markup regions and, for one template, url segments. The documentation recommends throwing a new Wire404Exception() from the template when the code concludes that the url segments from the request are invalid, and so we do.
      However, the 404 page is not displayed properly. Viewing the page source in the browser we can see that the original, unmodified markup region contents from our _init.php file is prepended to the correct html output, messing the whole page up.
      Any advice is greatly appreciated.
    • By dreerr
      Dear Communiy,
      My template basic-page does have URL segments activated. The segments are used to handle a different URL for the files attached. If a file is not found a Wire404Exception() is thrown. Sadly PagePathHistory does not handle it correctly (in my opinion) and old URLs no longer are redirected to the new ones.
      /** * Hook called upon 404 from ProcessPageView::pageNotFound * */ public function hookPageNotFound(HookEvent $event) { $page = $event->arguments[0]; // If there is a page object set, then it means the 404 was triggered // by the user not having access to it, or by the $page's template // throwing a 404 exception. In either case, we don't want to do a // redirect if there is a $page since any 404 is intentional there. if($page && $page->id) return; [...] The documentation makes sense here but is the opposite of the desired effect.
      Only solution for my problem was to disable the if-Statement, is there a better way to do this?
    • By k07n
      I rebuilding site from another CMS and need to redirect some old pages to new ones.
      Old scheme of urls is site.com/index.php?id=123
      I have this in _init.php:
      $id = (int)$input->get->id; if ($id > 0) { $redirect_page = wire('pages')->get("parent=/tools/old2new/, template=old2new-redirect, name=$id"); if ($redirect_page instanceof NullPage) { throw new Wire404Exception(); } else { $url = $redirect_page->redirect_to->url . $redirect_page->param; wire('session')->redirect($url); } } So, Wire404Exception() -- throw me this:
      Fatal error: Exception: (in \www\site\templates\_init.php line 21) #0 \www\wire\core\TemplateFile.php(139): require() #1 [internal function]: TemplateFile->___render() #2 \www\wire\core\Wire.php(359): call_user_func_array(Array, Array) #3 \www\wire\core\Wire.php(317): Wire->runHooks('render', Array) #4 \www\wire\modules\PageRender.module(337): Wire->__call('render', Array) #5 \www\wire\modules\PageRender.module(337): TemplateFile->render() #6 [internal function]: PageRender->___renderPage(Object(HookEvent)) #7 \www\wire\core\Wire.php(359): call_user_func_array(Array, Array) #8 \www\wire\core\Wire.php(317): Wire->runHooks('renderPage', Array) #9 \www\wire\core\Wire.php(381): Wire->__call('renderPage', Array) #10 \www\wire\core\Wire.php(381): PageRender->renderPage(O in \www\index.php on line 216 But if I use exception from another template it working fine and render 404 page. 
      Please help to fix it and maybe some suggestion to "redirect" code?
  • Create New...