Add error handling to menu JS