Skip to content

Commit f83fe54

Browse files
committed
docs: fix SQL error types — SqlParseError/SqlLexerError, not plain Error
The error-handling page claimed SQL errors throw standard Error. They actually throw SqlParseError or SqlLexerError with a position field. Updated with proper instanceof checks and imports.
1 parent ac7fb6f commit f83fe54

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

docs/src/content/docs/error-handling.mdx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ All errors thrown by QueryMode are `QueryModeError` instances with a structured
1111
|------|------|----------------|
1212
| `TABLE_NOT_FOUND` | File doesn't exist, R2 key missing | "Table not found: events.lance" |
1313
| `COLUMN_NOT_FOUND` | Column name not in schema | "Column not found: foo" |
14-
| `INVALID_FORMAT` | File can't be parsed as any supported format | "Invalid table format: data.xyz" |
14+
| `INVALID_FORMAT` | File can't be parsed as any supported format | "Invalid table format: data.xyz. Supported formats: .lance, .parquet, .csv, ..." |
1515
| `SCHEMA_MISMATCH` | Column exists but type doesn't match operation | "Column not found in events: age" |
1616
| `INVALID_FILTER` | Bad filter op or value type | "Invalid filter: unknown op 'regex'" |
1717
| `INVALID_AGGREGATE` | Bad aggregate function or missing column | "Invalid aggregate: sum requires numeric column" |
@@ -61,15 +61,23 @@ try {
6161

6262
Already-wrapped `QueryModeError` instances pass through unchanged.
6363

64-
## SQL parse errors
64+
## SQL errors
6565

66-
SQL syntax errors throw standard `Error` (not `QueryModeError`) with the parse position:
66+
SQL syntax errors throw `SqlParseError` or `SqlLexerError` (not `QueryModeError`) with a `position` field indicating where the error occurred:
6767

6868
```typescript
69+
import { SqlParseError, SqlLexerError } from "querymode"
70+
6971
try {
7072
await qm.sql("SELECT FROM").collect()
7173
} catch (err) {
72-
// "Expected column or expression at position 7"
73-
console.log(err.message)
74+
if (err instanceof SqlParseError) {
75+
console.log(err.message) // "Expected column or expression at position 7"
76+
console.log(err.position) // 7
77+
}
78+
if (err instanceof SqlLexerError) {
79+
console.log(err.message) // "Unexpected character at position 12"
80+
console.log(err.position) // 12
81+
}
7482
}
7583
```

0 commit comments

Comments
 (0)