added reason passing in error handlers