Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Catching an HttpServerErrorException
  • I’ve got a class I’ve written for an API. When there’s an error it throws a HttpServerErrorException, which is what I want when the user uses it.
    However, I run it as some tests in the Terminal, and it prints out the error page as default with FuelPHP.

    <!--?php

    namespace Fuel\Tasks;

    class Apitest
    {

    public static function run()
    {
    $api = new \Myapi;

    $api->set_params(\Config::get('apisettings'));

    try
    {
    echo $api-&gt;assets();
    }
    catch (HttpServerErrorException $e)
    {
    Cli::error($e);
    }
    }
    }

    I want it to let me overwrite it, so I can use Cli::error() or something similar to debug.
  • HarroHarro
    Accepted Answer
    You mean you still get the exception?

    Try \HttpServerErrorException, because the class is defined in the global namespace, not the Fuel\Tasks namespace.
  • D’oh, obviously! Thanks!

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion