김서영

handling searchdata and trycatch

......@@ -12,9 +12,9 @@ const cliConnection = async (req, res) => {
analyzeData = {},
searchData = [];
// clientData
try {
clientData = req.body.data;
//clientData = req.body.data;
if( !clientData.text.replace( /\s/g, '' ).length ) {
throw new Error( "client text empty" );
}
......@@ -26,6 +26,7 @@ const cliConnection = async (req, res) => {
return false;
}
// analyzeData
try {
analyzeData = await textAnalytic( clientData );
}
......@@ -36,7 +37,17 @@ const cliConnection = async (req, res) => {
return false;
}
// searchData try catch
// searchData
searchData = searchData[ 0 ].concat( searchData[ 1 ] );
try {
searchData = await machineRead( searchData, analyzeData.keywordText );
}
catch ( err ) {
console.log( err );
res.json( { "return_code" : -1, "error_code" : err.message } );
res.status( 502 );
return false;
}
analyzeData.searchResults = searchData;
res.send({ return_code: 0, return_data: analyzeData });
......