added try catch around sparql query for malformed queries

This commit is contained in:
Josip Milovac 2022-12-20 11:34:11 +11:00
parent b4c2a0c88d
commit 59bb42be11

View file

@ -241,6 +241,7 @@ app.post("/UploadMetafile", upload.single('file'), (req, res) => {
app.post('/sparql', (req, res) => { app.post('/sparql', (req, res) => {
console.log(req.body); console.log(req.body);
const start = async function () { const start = async function () {
try {
let result = []; let result = [];
const bindingsStream = await myEngine.queryBindings( const bindingsStream = await myEngine.queryBindings(
req.body, req.body,
@ -261,8 +262,14 @@ app.post('/sparql', (req, res) => {
bindingsStream.on('error', (err) => { bindingsStream.on('error', (err) => {
console.error(err); console.error(err);
}); });
} catch (err) {
console.error(err);
res.json("Error occured while querying");
}
}; };
start() start()
}); });
///////////////////////////////////////////////////////////Integration/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////Integration///////////////////////////////////////////////////////////