handles error responses from server and alerts to user res.error.message