Handle 401 and 404 with grace