From b1a8811ba6a45c8cb12d118eb2afe36bd61bd8df Mon Sep 17 00:00:00 2001
From: goodroot <9484709+goodroot@users.noreply.github.com>
Date: Mon, 20 Jan 2025 12:04:21 -0800
Subject: [PATCH] add error code start

---
 documentation/error-codes.md        | 14 ++++++++
 src/theme/ErrorCodesTable/index.tsx | 50 +++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
 create mode 100644 documentation/error-codes.md
 create mode 100644 src/theme/ErrorCodesTable/index.tsx

diff --git a/documentation/error-codes.md b/documentation/error-codes.md
new file mode 100644
index 00000000..55b630da
--- /dev/null
+++ b/documentation/error-codes.md
@@ -0,0 +1,14 @@
+---
+title: Error codes
+description: A list of error codes generated by QuestDB and their meanings.
+---
+
+import { ErrorCodesTable } from "../src/theme/ErrorCodesTable"
+
+## Open source
+
+<ErrorCodesTable type="opensource" />
+
+## Enterprise
+
+<ErrorCodesTable type="enterprise" />
\ No newline at end of file
diff --git a/src/theme/ErrorCodesTable/index.tsx b/src/theme/ErrorCodesTable/index.tsx
new file mode 100644
index 00000000..1930a706
--- /dev/null
+++ b/src/theme/ErrorCodesTable/index.tsx
@@ -0,0 +1,50 @@
+import Heading from '@theme/Heading'
+
+type ErrorCode = {
+  code: string
+  component: string
+  errno: string
+  summary: string
+  explanation: string
+  docLink?: string
+}
+
+// This is a stub - will be replaced with actual data from the repos later
+const errorCodes: ErrorCode[] = [
+  {
+    code: "ER001",
+    component: "replication",
+    errno: "001",
+    summary: "Replication target not found",
+    explanation: "QuestDB cannot establish a replication connection to the target instance. Check network connectivity, hostname, and firewall settings.",
+    docLink: "/docs/operations/replication/",
+  },
+  // More error codes will be added here from the core repo
+]
+
+type ErrorCodesTableProps = {
+  type?: "opensource" | "enterprise"
+}
+
+export const ErrorCodesTable = ({ type }: ErrorCodesTableProps) => {
+  const filteredErrors = type
+    ? errorCodes.filter(error => type === "enterprise" ? error.code.startsWith("EE") : !error.code.startsWith("EE"))
+    : errorCodes
+
+  return (
+    <div>
+      {filteredErrors.map((error) => (
+        <div key={error.code}>
+          <Heading as="h3" id={error.code}>{error.code}</Heading>
+          <p>{error.summary}</p>
+          <p>{error.explanation}</p>
+          {error.docLink && (
+            <a href={error.docLink}>
+              Learn more
+            </a>
+          )}
+        </div>
+      ))}
+    </div>
+  )
+} 
\ No newline at end of file