김서영

handling searchdata and trycatch

...@@ -12,9 +12,9 @@ const cliConnection = async (req, res) => { ...@@ -12,9 +12,9 @@ const cliConnection = async (req, res) => {
12 analyzeData = {}, 12 analyzeData = {},
13 searchData = []; 13 searchData = [];
14 14
15 + // clientData
15 try { 16 try {
16 clientData = req.body.data; 17 clientData = req.body.data;
17 - //clientData = req.body.data;
18 if( !clientData.text.replace( /\s/g, '' ).length ) { 18 if( !clientData.text.replace( /\s/g, '' ).length ) {
19 throw new Error( "client text empty" ); 19 throw new Error( "client text empty" );
20 } 20 }
...@@ -26,6 +26,7 @@ const cliConnection = async (req, res) => { ...@@ -26,6 +26,7 @@ const cliConnection = async (req, res) => {
26 return false; 26 return false;
27 } 27 }
28 28
29 + // analyzeData
29 try { 30 try {
30 analyzeData = await textAnalytic( clientData ); 31 analyzeData = await textAnalytic( clientData );
31 } 32 }
...@@ -36,7 +37,17 @@ const cliConnection = async (req, res) => { ...@@ -36,7 +37,17 @@ const cliConnection = async (req, res) => {
36 return false; 37 return false;
37 } 38 }
38 39
39 - // searchData try catch 40 + // searchData
41 + searchData = searchData[ 0 ].concat( searchData[ 1 ] );
42 + try {
43 + searchData = await machineRead( searchData, analyzeData.keywordText );
44 + }
45 + catch ( err ) {
46 + console.log( err );
47 + res.json( { "return_code" : -1, "error_code" : err.message } );
48 + res.status( 502 );
49 + return false;
50 + }
40 51
41 analyzeData.searchResults = searchData; 52 analyzeData.searchResults = searchData;
42 res.send({ return_code: 0, return_data: analyzeData }); 53 res.send({ return_code: 0, return_data: analyzeData });
......