message: fix(core): improve error response string creation
  If there is no body on a response object, creating a string from the error
  response will fail with: `TypeError: Cannot read property 'error' of null`.
  Instead, check to make sure `res.body` exists before using.
  Ticket:
diff: @@ -93,11 +93,10 @@ export function handleResponseError(e: Error & { response?: superagent.Response
  */
  function createResponseErrorString(res: superagent.Response): string {
  let errString = res.status.toString(); // at the very least we'll have the status code
  - if (res.body.error) {
  + if (res.body?.error) {
  // this is the case we hope for, where the server gives us a nice error from the JSON body
  errString = res.body.error;
  - } else {
  - if (res.text) {
  + } else if (res.text) {
  // if the response came back as text, we try to parse it as HTML and remove all tags, leaving us
  // just the bare text, which we then trim of excessive newlines and limit to a certain length
  try {
  @@ -110,12 +109,7 @@ function createResponseErrorString(res: superagent.Response): string {
  errString = errString + '\n' + sanitizedText; // add it to our existing errString (at this point the more info the better!)
  } catch (e) {
  // do nothing, the response's HTML was too wacky to be parsed cleanly
  - debug(
  - 'got error with message "%s" while creating response error string from response: %s',
  - e.message,
  - res.text
  - );
  - }
  + debug('got error with message "%s" while creating response error string from response: %s', e.message, res.text);
  }
  }
  