Fix the error handling middleware so the functions have 4 arguments