Improved error handling for login
Improved, but not completed error handling for getting posts