Edit controller to return error messages when needed