Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
error_handling in fuel tasks how to allow to continue with the task execution
  • FuelPhp stops the execution when there is an error (it doesn't matter if it's fatal, warning, strict...etc) running fuel tasks.

    For example running: "php oil r mytask" with a warning error.

    The logic is into command.php L110 and it stops the execution doing an exit(1)

    I need to find a way to skip this stop and override this behaviour since we want to continue the execution but reporting php errors.

    The code there is:

    // Developers of third-party tasks may not be displaying PHP errors. Report any error and quit

    set_error_handler(function($errno, $errstr, $errfile, $errline) {

    if (!error_reporting()) return; // If the error was supressed with an @ then we ignore it!

    \Cli::error("Error: {$errstr} in $errfile on $errline");

    \Cli::beep();

    exit(1);

    });

    But when there is a client call FuelPHP uses \Config::get('errors.continue_on') to get the configured settings and it would have more sense to take in account the same configuration.

    How can I skip this stop?

    Thanks.

  • HarroHarro
    Accepted Answer
    Your code should be error free, so any errors should be fixed, not ignored.

    If it is an error you can recover from, use a try/catch block in your code to catch the exception and handle it.
  • Hi Harro,

    But the problem here is that I can't do a try catch into the task since FuelPHP is stopping the execution. I don't want to stop the execution when there is a warning error for example.

    Thanks.
  • FuelPHP doesn't generate errors, your code does. *)

    So look in the backtrace to see what in your code is causing the error, and fix it so it doesn't. Or put that in a try/catch block. Everything in Fuel is an exception, even standard PHP notices, warnings, etc. And can be caught.

    *) disclaimer: if it does, you've just found a bug, let us know so it can be fixed.
  • Hi Harro,

    If you take a look at /fuel/packages/oil/classes/command.php L110 you will see the exit(1) it's not throwing an exception.

    It would be more sense to throw an exception or even better to check the \Config::get('errors.continue_on') value first and continue with the execution (as the base error handler does) else throw an exception.

    Victor.
  • Which version of Fuel are you on? This has been vastly improved in 1.6.
  • Hi Harro,

    We're not using the last version. We're going to update it and I saw this improved part.

    Thanks!

Howdy, Stranger!

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

In this Discussion