private _extractErrorMessage()

in src/auth/auth-core.ts [784:811]


  private _extractErrorMessage(error: Error | AuthError | undefined, logError = false) {
    if (!error) {
      return null;
    }
    if (logError) {
      // eslint-disable-next-line no-console
      console.error('RingUI Auth error', error);
    }

    try {
      // We've got some error from this list
      // https://www.jetbrains.com/help/youtrack/devportal/OAuth-2.0-Errors.html
      if (
        'code' in error &&
        error.code &&
        typeof error.code === 'object' &&
        'code' in error.code &&
        typeof error.code.code === 'string'
      ) {
        const readableCode = error.code.code.split('_').join(' ');
        return `Authorization error: ${readableCode}`;
      }
    } catch {
      // noop
    }

    return error.toString ? error.toString() : null;
  }