Showing
1 changed file
with
23 additions
and
1 deletions
... | @@ -10,11 +10,33 @@ const machineRead = require("./machineRead"); | ... | @@ -10,11 +10,33 @@ const machineRead = require("./machineRead"); |
10 | const cliConnection = async (req, res) => { | 10 | const cliConnection = async (req, res) => { |
11 | let clientData = {}, | 11 | let clientData = {}, |
12 | analyzeData = {}, | 12 | analyzeData = {}, |
13 | + searchData = []; | ||
13 | 14 | ||
15 | + try { | ||
14 | clientData = req.body.data; | 16 | clientData = req.body.data; |
15 | //clientData = req.body.data; | 17 | //clientData = req.body.data; |
18 | + if( !clientData.text.replace( /\s/g, '' ).length ) { | ||
19 | + throw new Error( "client text empty" ); | ||
20 | + } | ||
21 | + } | ||
22 | + catch ( err ) { | ||
23 | + console.log( err ); | ||
24 | + res.json( { "return_code" : -1, "error_code" : err.message } ); | ||
25 | + res.status( 403 ); | ||
26 | + return false; | ||
27 | + } | ||
16 | 28 | ||
17 | - analyzeData = await textAnalytic(clientData); | 29 | + try { |
30 | + analyzeData = await textAnalytic( clientData ); | ||
31 | + } | ||
32 | + catch ( err ) { | ||
33 | + console.log( err ); | ||
34 | + res.json( { "return_code" : -1, "error_code" : err.message } ); | ||
35 | + res.status( 502 ); | ||
36 | + return false; | ||
37 | + } | ||
38 | + | ||
39 | + // searchData try catch | ||
18 | 40 | ||
19 | analyzeData.searchResults = searchData; | 41 | analyzeData.searchResults = searchData; |
20 | res.send({ return_code: 0, return_data: analyzeData }); | 42 | res.send({ return_code: 0, return_data: analyzeData }); | ... | ... |
-
Please register or login to post a comment