Adds check before displaying error stack.

This check will make sure that the error property is actually defined before trying
to dislpay the object's stack trace.