Add xhr error catching

The xhr module currently does not catch connection errors from no network connection (caught by xhr.onerror) or from a non-valid status code in the response.