Tag Archive: exception


Debugging a Twig View

Just a quick note here to save future hunting.

Ever seen this crap error message?

An exception has been thrown during the rendering of a templat

It totally sucks, right? And then you try debugging with XDebug, only to find you can’t most of the time, since Twig uses eval().

Anyway, to save you looking, if you set a breakpoint where that message is thrown you can get to see your own Exception:

vendor/twig/twig/lib/Twig/Template.php

Look at line 401 (this may have changed in later versions):

} catch (Exception $e) {
    throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getTemplateName(), $e);
}

You can now see your Exception!

Hi!

This job seems to get more interesting and fun by the day!

Today, it’s Magento! The mission? To move an existing Magento Store from Live hosting out there to another hosting provider, and then reskin it. And inbetween we’re going to miove it onto my local apache install.

Download the files, and setup your hosts and vhosts as per usual. However! localhost or whatever you call it will not be enough apparently, it likes a FQDN (fully qualified domain name.), so I called mine http://magentolab.del

Export the MySQL DB. Apparently the best way to do that is through the admin section of the magento site, as PHP MyAdmin does not bother with the Foreign Key Constraints of InnoDB, and you may get import errors if you do it that way. Your mileage may vary.

Import your SQL dump into MySQL, then run this command (your tables may or may not have the ‘mage_’ prefix, delete as appropriate)

select * from mage_core_config_data where path like "%base_url%"

Change the url to your local address. Put a trailing slash on the end of it!! Restart Apache, browse to your site, and watch it FAIL! Ok, now to set it up some more. Open it up in your favourite IDE, and look for app/etc/local.xml.
That’s where you’ll find settings regarding your DB connection. Edit to suit.

Now, you’ll probably not be getting to see your exceptions on screen. You’ll find them hidden away in var/report.

In my case, I was getting an exception that stated: Illegal scheme supplied, only alphanumeric characters are permitted

Again, the FQDN issue I described was part of this, but not all. We need to comment some other stuff out.
Dig into the app/code/core/Mage/Core/Model/Session/Abstract/ folder and open Varien.php. Jump to line 85 (as of v1.6.1)
Comment out some of the array like so:

  // session cookie params
        $cookieParams = array(
            'lifetime' => $cookie->getLifetime(),
            'path'     => $cookie->getPath(),
          /*  'domain'   => $cookie->getConfigDomain(),
            'secure'   => $cookie->isSecure(),
            'httponly' => $cookie->getHttponly() */
        );

If you’ve done everything correctly, you should have your live site running on your development machine! I’m guessing reverse that process to get it to my new live server! Have Fun