File tree Expand file tree Collapse file tree 3 files changed +33
-11
lines changed
Expand file tree Collapse file tree 3 files changed +33
-11
lines changed Original file line number Diff line number Diff line change @@ -86,15 +86,21 @@ const sendAnswer = (req, res) => {
8686 delimiters : [ "{" , "}" ] ,
8787 } ) ;
8888
89- const {
90- amount,
91- unitFrom,
92- unitTo,
93- } = valuesObj ;
94-
9589 rating = 1 ;
9690 action = "unit_converter" ;
97- responseText = changeUnit ( amount , unitFrom , unitTo ) ;
91+
92+ try {
93+ const {
94+ amount,
95+ unitFrom,
96+ unitTo,
97+ } = valuesObj ;
98+
99+ responseText = changeUnit ( amount , unitFrom , unitTo ) ;
100+ } catch ( error ) {
101+ responseText = "One or more unit missing." ;
102+ console . log ( error ) ;
103+ }
98104 } else {
99105 const similarQuestionObj = stringSimilarity . findBestMatch ( humanInput , allQustions ) . bestMatch ;
100106 const similarQuestionRating = similarQuestionObj . rating ;
Original file line number Diff line number Diff line change 11[
2- " change {amount} {unit_from} into {unit_to}" ,
3- " can you convert {amount} {unit_from} to {unit_to}" ,
4- " convert {amount} {unit_from} into {unit_to}" ,
5- " how many {unit_to} in {amount} {unit_from}"
2+ " change {amount} {unitFrom} into {unitTo}" ,
3+ " change {amount} {unitFrom} to {unitTo}" ,
4+ " can you convert {amount} {unitFrom} to {unitTo}" ,
5+ " convert {amount} {unitFrom} into {unitTo}" ,
6+ " how many {unitTo} in {amount} {unitFrom}"
67]
Original file line number Diff line number Diff line change 1+ {
2+ "version" : 2 ,
3+ "builds" : [
4+ {
5+ "src" : " index.js" ,
6+ "use" : " @vercel/node"
7+ }
8+ ],
9+ "routes" : [
10+ {
11+ "src" : " /(.*)" ,
12+ "dest" : " /"
13+ }
14+ ]
15+ }
You can’t perform that action at this time.
0 commit comments