Call error handler if it is defined
Merge pull request #1 from jgrau/error-handling

Call error handler if it is defined