Skip to content

Commit cc39b07

Browse files
committed
parser errors + test
1 parent 12ce446 commit cc39b07

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

parser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pgsql/parser",
3-
"version": "1.0.4",
3+
"version": "1.0.5",
44
"author": "Dan Lynch <[email protected]>",
55
"description": "Multi-version PostgreSQL parser with dynamic version selection",
66
"main": "./wasm/index.cjs",

parser/templates/index.cjs.template

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class Parser {
2626
try {
2727
return this.parser.parse(query);
2828
} catch (error) {
29+
// Preserve the original error if it's a SqlError
30+
if (error.name === 'SqlError') {
31+
throw error;
32+
}
2933
throw new Error(`Parse error in PostgreSQL ${this.version}: ${error.message}`);
3034
}
3135
}
@@ -37,6 +41,10 @@ class Parser {
3741
try {
3842
return this.parser.parseSync(query);
3943
} catch (error) {
44+
// Preserve the original error if it's a SqlError
45+
if (error.name === 'SqlError') {
46+
throw error;
47+
}
4048
throw new Error(`Parse error in PostgreSQL ${this.version}: ${error.message}`);
4149
}
4250
}

parser/templates/index.js.template

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ export class Parser {
2626
try {
2727
return this.parser.parse(query);
2828
} catch (error) {
29+
// Preserve the original error if it's a SqlError
30+
if (error.name === 'SqlError') {
31+
throw error;
32+
}
2933
throw new Error(`Parse error in PostgreSQL ${this.version}: ${error.message}`);
3034
}
3135
}
@@ -37,6 +41,10 @@ export class Parser {
3741
try {
3842
return this.parser.parseSync(query);
3943
} catch (error) {
44+
// Preserve the original error if it's a SqlError
45+
if (error.name === 'SqlError') {
46+
throw error;
47+
}
4048
throw new Error(`Parse error in PostgreSQL ${this.version}: ${error.message}`);
4149
}
4250
}

0 commit comments

Comments
 (0)