message: Reorganize auth token error handling to hopefully catch stuff better
diff: @@ -131,19 +131,14 @@ async function handleRefreshTokenError(response: Error | Response): Promise<Toke
  );
  throw response;
  }
  - switch (response.status) {
  - case -1:
  - throw new Error(
  - "Error getting auth token from refresh token because there's no internet connection. Not clearing token."
  - );
  - case 400:
  - case 401:
  - case 403: {
  +
  let data;
  try {
  data = await response.json();
  } catch (e) {}
  - if (data?.error === 'server_error') {
  +
  + if (data) {
  + if (data.error === 'server_error') {
  if (data.error_description === 'SystemDisabled') {
  throw new Error(t('BungieService.Maintenance'));
  } else if (data.error_description !== 'AuthorizationRecordExpired') {
  @@ -152,12 +147,8 @@ async function handleRefreshTokenError(response: Error | Response): Promise<Toke
  );
  }
  }
  - throw new FatalTokenError('Refresh token expired or not valid, status ' + response.status);
  - }
  - default: {
  - try {
  - const data = await response.json();
  - if (data?.ErrorCode) {
  +
  + if (data.ErrorCode) {
  switch (data.ErrorCode) {
  case PlatformErrorCodes.RefreshTokenNotYetValid:
  case PlatformErrorCodes.AccessTokenHasExpired:
  @@ -168,10 +159,19 @@ async function handleRefreshTokenError(response: Error | Response): Promise<Toke
  );
  }
  }
  - } catch (e) {
  - throw new Error("Error response wasn't json: " + e.message);
  }
  +
  + switch (response.status) {
  + case -1:
  + throw new Error(
  + "Error getting auth token from refresh token because there's no internet connection. Not clearing token."
  + );
  + case 400:
  + case 401:
  + case 403: {
  + throw new FatalTokenError('Refresh token expired or not valid, status ' + response.status);
  }
  }
  +
  throw new Error('Unknown error getting response token: ' + JSON.stringify(response));
  }
  