Improve authentication error handling