Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Exception
  • Hi.,
    I hosted my project in server.,When open the file it show the error

    ErrorException [ Fatal Error ]:

    Method Fuel\Core\View::__toString() must not throw an exception
  • What version of Fuel are you on? There's an exception handler in __toString() since at least 1.3.

    If the exception handler itself throws an exception as well, you'll have to do a bit of debugging. Change __toString() to:

        public function __toString()
        {
            try
            {
                return $this->render();
            }
            catch (\Exception $e)
            {
                try
                {
                    \Errorhandler::exception_handler($e);
                }
                catch (\Exception $e)
                {
                    var_dump($e);
                    die();
                }
                return '';
            }
        }

    and see if the exception is now dumped. Don't forget to remove this code once you've found the problem.
  • Thanks for replying.,
    I am using Fuel 1.7.3.,
    I am not using toString() function in any part of my code.,
  • HarroHarro
    Accepted Answer
    http://php.net/manual/en/language.oop5.magic.php#object.tostring

    Note the big red warning, which is what your problem is.

    It is called automatically if you echo a View object, or if you do something with the object that requires conversion from object to string. If your controllers return a View object, or a Response object with a View in it, it will be echo'd out in your index.php.

    The only way to find out what is causing it, is the code above. Most likely your View object constains a body that can not be converted to string, or contains something that causes the exception to be caught, but in turn causes a further error in the error handler.

    The code is the quickest way to determine what is causing the problem.

Howdy, Stranger!

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

In this Discussion