Recently I was trying to define a custom exception for 503 http status code, to my suprise, Fuel is of course allowing to do so, but in a very retarded way.
I have created httpexceptions.php file with
class HttpServiceUnavailableException extends \Fuel\Core\HttpException { public function response() { return new \Response('<h2>Service Unavailable - we will be back soon</h2>', 503); } }
Now, everything is fine until we have a _503_ route defined, in case we doesn't Fuel wont use a default response passed (<h2>Service Unavailable - we will be back soon</h2> in my case) like it does for 403, 404, 500 errors and throw a 404 error instead.
This happens because Fuel is forcing reserved modules for a request:
The reserve_routes snippet is only relevant in case of modules with their own route file, and it is there to make sure that when module routes are loaded, routes like _404_ are not converted to module/_404_.
It has nothing to do with what you are experiencing.
You get the 404 because although you have altered your index.php to handle your exception via a _503_ route, you haven't actually defined the _503_ route. So you get the 404 as a result of that route lookup.
This in turn is because the routerequest closure also handles other route requests. The 404 you have is generated by
You did explain what I already know. I wrote the thread to either fix this or make a note of that in the docs. If someone would try to handle new http status errors the way it's done in Fuel core, he will fail. Returning a response object from the extended exception class is pointless then because it will never get used... and I seen few people did that already on github ;-)