김서영

api try catch - clienddata and analyzeData

......@@ -10,15 +10,37 @@ const machineRead = require("./machineRead");
const cliConnection = async (req, res) => {
let clientData = {},
analyzeData = {},
searchData = [];
clientData = req.body.data;
//clientData = req.body.data;
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;
}
try {
analyzeData = await textAnalytic( clientData );
}
catch ( err ) {
console.log( err );
res.json( { "return_code" : -1, "error_code" : err.message } );
res.status( 502 );
return false;
}
analyzeData = await textAnalytic(clientData);
// searchData try catch
analyzeData.searchResults = searchData;
res.send({ return_code: 0, return_data: analyzeData });
res.status(200);
};
module.exports = cliConnection;
module.exports = cliConnection;
\ No newline at end of file
......