김서영

api try catch - clienddata and analyzeData

......@@ -10,11 +10,33 @@ const machineRead = require("./machineRead");
const cliConnection = async (req, res) => {
let clientData = {},
analyzeData = {},
searchData = [];
try {
clientData = req.body.data;
//clientData = req.body.data;
if( !clientData.text.replace( /\s/g, '' ).length ) {
throw new Error( "client text empty" );
}
}
catch ( err ) {
console.log( err );
res.json( { "return_code" : -1, "error_code" : err.message } );
res.status( 403 );
return false;
}
analyzeData = await textAnalytic(clientData);
try {
analyzeData = await textAnalytic( clientData );
}
catch ( err ) {
console.log( err );
res.json( { "return_code" : -1, "error_code" : err.message } );
res.status( 502 );
return false;
}
// searchData try catch
analyzeData.searchResults = searchData;
res.send({ return_code: 0, return_data: analyzeData });
......