Error Handling in Magento: How to Enable Error Display

How to handle Magento errors

One of the difficult issues in any programming language is to work with errors. There are different types of errors such as Fatal errors, notice errors, warnings and different ways to handle them. In Magento 1.4 and above, errors are not displayed to visitors on the front end but rather stored in a log file. Developers can navigate to /var/report folder to know about the error.

Pros & Cons of this Approach:

This is, on the one hand, good as error messages can contain information which intruders can use to compromise your system. On the other hand, developers especially newcomers can find it difficult to figure out what is actually going wrong. Besides, they have to navigate to the log file every time they want to find information about the error. Luckily, you can always enable error-display option.

How to Enable Error-Display:

It’s pretty easy to enable displaying error on screen. Just follow the steps below.

  1. Navigate to /errors folder in the root Magento installation folder.
  2. Rename the file local.xml.sampleto local.xml.
  3. This file should contain the following lines of code.
<config>
<skin>default</skin>
<report>
<action>print</action>
<trash>leave</trash>
</report>
</config>

The “print” in the “action” tag suggests that errors be displayed on screen.

Send an Email if an error occurs:

Even cooler, you can also configure it to send you an email when an error occurs.

<config>
<skin>default</skin>
<report>
<action>email</action>
<subject>Magento Error Notification</subject>
<email_address>admin@magento-store.com</email_address>
<trash>leave</trash>
</report>
</config>

In the “subject” tag, you can provide an appropriate subject of the email and specify an email address to which you want to send the email in the “email_address” tag.

Leave a Reply

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