Added basic error handling depending on what type of response was given from the request