Handling and logging exception generated in registered script.

This change would make it easy to track unhanded exceptions, as every exceptions would be logged.