Passing next as a parameter to error handling