67 lines · 2.3 KB
/** What each HTTP failure looks like to a person. Lines in `command` read like git's own output. */
export type ErrorKind =
  | "unauthorized"
  | "forbidden"
  | "not-found"
  | "rate-limited"
  | "client"
  | "server"
  | "unavailable";

export type ErrorCopy = { title: string; description: string; command: string };

export const ERROR_COPY: Record<ErrorKind, ErrorCopy> = {
  unauthorized: {
    title: "Sign in to keep going.",
    description: "This page needs an account. Sign in, or create one — it only takes a moment.",
    command: "fatal: Authentication required",
  },
  forbidden: {
    title: "This one's behind a locked door.",
    description:
      "You're signed in, but you don't have access here. Ask an owner of the repository or organization to add you.",
    command: "remote: Permission denied",
  },
  "not-found": {
    title: "This branch doesn't lead anywhere.",
    description: "The page may have moved or been deleted — or it's private and you don't have access to it.",
    command: "fatal: couldn't find remote ref",
  },
  "rate-limited": {
    title: "Easy there.",
    description: "You've made a lot of requests in a short time. Wait a moment, then try again.",
    command: "remote: rate limit exceeded",
  },
  client: {
    title: "That request didn't go through.",
    description: "Something about it wasn't quite right. Go back and try again.",
    command: "error: request rejected",
  },
  server: {