export function createErrorMessage()

in firestore-palm-chatbot/functions/src/errors.ts [15:29]


export function createErrorMessage(e: unknown): string {
  if (!(e instanceof Error)) {
    return 'Unknown Error. Please look to function logs for more details.';
  }

  if (isGoogleErrorWithReason(e)) {
    switch (e.reason) {
      case GoogleErrorReason.ACCESS_TOKEN_SCOPE_INSUFFICIENT:
        return 'The project or service account likely does not have access to the PaLM API.';
      default:
        return `An error occurred while processing the provided message, ${e.message}`;
    }
  }
  return `An error occurred while processing the provided message, ${e.message}`;
}