diff --git a/README.md b/README.md index bcb0baf..a948a52 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,14 @@ session.query("USE testdb; INSERT INTO testtable VALUES (1), (2), (3);") ret = session.query("SELECT * FROM testtable;") console.log("Session Query Result:", ret); +// If an error occurs, it will be thrown +try { + session.query("SELECT * FROM non_existent_table;", "CSV"); +} +catch (e) { + console.log("Error:", e.message); +} + // Clean up the session session.cleanup(); diff --git a/example.js b/example.js index ff98bf8..72d400a 100644 --- a/example.js +++ b/example.js @@ -19,5 +19,13 @@ session.query("USE testdb; INSERT INTO testtable VALUES (1), (2), (3);") ret = session.query("SELECT * FROM testtable;") console.log("Session Query Result:", ret); +// Test error handling +try { + session.query("SELECT * FROM non_existent_table;", "CSV"); +} +catch (e) { + console.log("Error:", e.message); +} + // Clean up the session session.cleanup(); diff --git a/package.json b/package.json index b6e6edc..d3b89ff 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,14 @@ }, "scripts": { "install": "npm run libchdb && npm run build", - "test": "mocha", + "test": "mocha --timeout 5000", "libchdb": "curl -sL https://lib.chdb.io | bash && cp -a /usr/local/lib/libchdb.so ./ && cp -a /usr/local/include/chdb.h ./", "fixloaderpath": "./fix_loader_path.sh", "build": "node-gyp configure build --verbose && npm run fixloaderpath" }, "author": { "name": "chdb", - "email": "me@chdb.io" + "email": "auxten@clickhouse.com" }, "license": "Apache-2.0", "devDependencies": {