Add error handling to redirect helper