function handleError()

in src/components/config/config.ts [14:42]


function handleError(response: AnyError | AppConfig, ytUrl: string) {
  ytUrl = ytUrl.replace(VERSION_DETECT_FALLBACK_URL, '');

  //Handle very old (6.5 and below) instances
  if ('error' in response && response.error === 'Not Found') {
    throw new Error(
      `Cannot connect to ${ytUrl} - this version of YouTrack is not supported. ${YT_SUPPORTED_VERSION}`,
    );
  }

  //Handle config load error
  if ('error_developer_message' in response && response.error_developer_message) {
    throw new Error(
      `Unable to connect to this YouTrack instance. ${YT_SUPPORTED_VERSION} ${response.error_developer_message}`,
    );
  }

  const res = response as AppConfig;
  if (!res?.version || parseFloat(res.version) < MIN_YT_VERSION) {
    throw new Error(YT_SUPPORTED_VERSION);
  }

  if (!res?.mobile?.serviceId) {
    throw new Error(
      `The mobile application feature is not enabled for ${ytUrl}. Please contact support.`,
    );
  }
  return res;
}