Commit f2554d11a42f34eb1b58c823dbf92938f48162f3
1 parent
4e7bd6d333
Exists in
master
penanganan http 404
Showing 1 changed file with 17 additions and 11 deletions Side-by-side Diff
partner-bayarkilat.js
... | ... | @@ -4,7 +4,6 @@ var winston = require('winston'); |
4 | 4 | var xml2jsParser = require('xml2js').parseString; |
5 | 5 | var redis = require('redis'); |
6 | 6 | |
7 | - | |
8 | 7 | var config; |
9 | 8 | var aaa; |
10 | 9 | var callbackReport; |
... | ... | @@ -163,26 +162,33 @@ function requestToPartner(methodName, task, retry) { |
163 | 162 | |
164 | 163 | if (response.statusCode != 200) { |
165 | 164 | var message = 'Partner response with http status code other that 200 (' + response.statusCode + ')'; |
165 | + var rc = '68'; | |
166 | + | |
167 | + if (!retry && response.statusCode == 404) { | |
168 | + rc = '91'; | |
169 | + } | |
166 | 170 | |
167 | 171 | logger.warn(message); |
168 | - callbackReport(task.requestId, '68', message); | |
172 | + callbackReport(task.requestId, rc, message); | |
169 | 173 | |
170 | 174 | var _response = { |
171 | - raw: 'Partner response with http status code other that 200 (' + response.statusCode + ')', | |
175 | + raw: message, | |
172 | 176 | parsed: { |
173 | - MESSAGE: 'Partner response with http status code other that 200 (' + response.statusCode + ')', | |
177 | + MESSAGE: message, | |
174 | 178 | responseHttpStatus: response.statusCode, |
175 | 179 | responseBody: body, |
176 | 180 | } |
177 | 181 | } |
178 | - aaa.pushResponseToMongoDb(task, _response, '68'); | |
182 | + aaa.pushResponseToMongoDb(task, _response, rc); | |
179 | 183 | |
180 | - setTimeout( | |
181 | - topupCheck, | |
182 | - delayBeforeCheckRetry, | |
183 | - task, | |
184 | - retry | |
185 | - ); | |
184 | + if (rc == '68') { | |
185 | + setTimeout( | |
186 | + topupCheck, | |
187 | + delayBeforeCheckRetry, | |
188 | + task, | |
189 | + retry | |
190 | + ); | |
191 | + } | |
186 | 192 | |
187 | 193 | return; |
188 | 194 | } |