Fixing issue #1084 : Added error event handler