[TomatoCart] – Simple & powerful stacked error handling system

In this article, I will introduce you a simple yet powerful stacked error handling system for your store. If you are a developer, it should be very useful for you to debug your application code. If there is any exception or error thrown in the system , you will see a detailed error message as follow:

Snip20151220_2

Snip20151220_2

As you can see, you could see what’s the error happened and detailed request and server data. This is very useful to clear the error for a developer.

How to apply this debug system for your store?

Step 1. Create a composer.json under your tomatocart root directory with following content:

{
    "require": {
        "filp/whoops": "^1.1"
    },
    "config": {
        "vendor-dir": "ext"
    }
}

Note: you have to install the composer. If you haven’t installed it, please read my another article ahttp://blog.arvixe.com/tomatocart-use-composer-to-manage-php-dependency-in-tomatocart/

Step 2. Run following command within your TomatoCart root directory:

composer install

Step 3. Open includes > application_top.php with your favourite text editor.

— Find following code:

 if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
    error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_DEPRECATED);
  } else {
    error_reporting(E_ALL & ~E_NOTICE);
  }

— Add following code after it:

include('ext/autoload.php');

  $whoops = new \Whoops\Run;
  $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
  $whoops->register();

Step 4. Open admin > includes > application_top.php with your favourite text editor.

— Find following code:

if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
    error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE & ~E_DEPRECATED);
  } else {
    error_reporting(E_ALL & ~E_NOTICE);
  }

— Add following code after it:

 include('../ext/autoload.php');

  $whoops = new \Whoops\Run;
  $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
  $whoops->register();

Done. Now, when any error happened during your development, you will see the detailed error report and clear the error effectively.

Looking for quality TomatoCart hosting? Check out Arvixe Web Hosting

Tags: , , , , , , | Posted under TomatoCart | RSS 2.0

Author Spotlight

Jack Yin

TomatoCart Developer & Co Founder - Arvixe Web Hosting / TomatoCart Community Liaison

Leave a Reply

Your email address will not be published. Required fields are marked *