Commit ee5a6e87a179dc469e64e38b166b829f64c07a4a
1 parent
5c0335fe26
Exists in
master
simplified try catch
Showing 1 changed file with 5 additions and 10 deletions Side-by-side Diff
partner-datacell.js
... | ... | @@ -115,9 +115,9 @@ function topupResponseHandler(body, request_id) { |
115 | 115 | |
116 | 116 | var message = ''; |
117 | 117 | try { |
118 | - if (result.datacell.message.length > 0) { | |
118 | + if (result.datacell.message && result.datacell.message.length > 0) { | |
119 | 119 | message = result.datacell.message[0].trim(); |
120 | - } else if (result.datacell.msg.length > 0) { | |
120 | + } else if (result.datacell.msg && result.datacell.msg.length > 0) { | |
121 | 121 | message = result.datacell.msg[0].trim(); |
122 | 122 | } |
123 | 123 | } |
... | ... | @@ -125,16 +125,11 @@ function topupResponseHandler(body, request_id) { |
125 | 125 | message = 'exception saat parsing message'; |
126 | 126 | } |
127 | 127 | |
128 | - | |
129 | - try { | |
130 | - if (result.datacell.resultcode[0] == '999') { | |
131 | - response_code = '40'; | |
132 | - } | |
133 | - } | |
134 | - catch(err) { | |
135 | - response_code = '68'; | |
128 | + if (result.datacell.resultcode && result.datacell.resultcode[0] == '999') { | |
129 | + response_code = '40'; | |
136 | 130 | } |
137 | 131 | |
132 | + | |
138 | 133 | if (message.indexOf('Nomor tujuan salah') >= 0) { |
139 | 134 | response_code = '14'; |
140 | 135 | } else if (message.indexOf('*GAGAL, transaksi yang sama sudah ada dalam 10 menit') >= 0) { |