Skip to content

Commit da6903c

Browse files
committed
Add exception handling in example
1 parent 2bbe5a8 commit da6903c

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ session.query("USE testdb; INSERT INTO testtable VALUES (1), (2), (3);")
3535
ret = session.query("SELECT * FROM testtable;")
3636
console.log("Session Query Result:", ret);
3737

38+
// If an error occurs, it will be thrown
39+
try {
40+
session.query("SELECT * FROM non_existent_table;", "CSV");
41+
}
42+
catch (e) {
43+
console.log("Error:", e.message);
44+
}
45+
3846
// Clean up the session
3947
session.cleanup();
4048

example.js

+8
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,13 @@ session.query("USE testdb; INSERT INTO testtable VALUES (1), (2), (3);")
1919
ret = session.query("SELECT * FROM testtable;")
2020
console.log("Session Query Result:", ret);
2121

22+
// Test error handling
23+
try {
24+
session.query("SELECT * FROM non_existent_table;", "CSV");
25+
}
26+
catch (e) {
27+
console.log("Error:", e.message);
28+
}
29+
2230
// Clean up the session
2331
session.cleanup();

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
},
1010
"scripts": {
1111
"install": "npm run libchdb && npm run build",
12-
"test": "mocha",
12+
"test": "mocha --timeout 5000",
1313
"libchdb": "curl -sL https://lib.chdb.io | bash && cp -a /usr/local/lib/libchdb.so ./ && cp -a /usr/local/include/chdb.h ./",
1414
"fixloaderpath": "./fix_loader_path.sh",
1515
"build": "node-gyp configure build --verbose && npm run fixloaderpath"
1616
},
1717
"author": {
1818
"name": "chdb",
19-
"email": "[email protected]"
19+
"email": "[email protected]"
2020
},
2121
"license": "Apache-2.0",
2222
"devDependencies": {

0 commit comments

Comments
 (0)