Commit 3f955eb49b47f74642ca7dfa318662c9a0f7b2e3
1 parent
6e24b7ddee
Exists in
master
try catch
Showing 1 changed file with 23 additions and 6 deletions Side-by-side Diff
xmlrpc-server.js
... | ... | @@ -296,6 +296,25 @@ function sendReply(response) { |
296 | 296 | }); |
297 | 297 | } |
298 | 298 | |
299 | +function errorOnTopUpReport(topUpReportError) { | |
300 | + var hasError = false; | |
301 | + | |
302 | + if (!topUpReportError) { | |
303 | + return false; | |
304 | + } | |
305 | + | |
306 | + try { | |
307 | + if (topUpReportError.toString().indexOf('Invalid XML-RPC message') < 0) { | |
308 | + return true; | |
309 | + } | |
310 | + } | |
311 | + catch(e) { | |
312 | + } | |
313 | + | |
314 | + return false; | |
315 | + | |
316 | +} | |
317 | + | |
299 | 318 | function sendTopUpReport(reverseUrls, params, urlIdx, retry) { |
300 | 319 | if (retry === null || retry === undefined) { |
301 | 320 | retry = 1; |
... | ... | @@ -346,14 +365,12 @@ function sendTopUpReport(reverseUrls, params, urlIdx, retry) { |
346 | 365 | |
347 | 366 | client.methodCall(methodName, [ params ], function (topUpReportError, value) { |
348 | 367 | |
349 | - if (topUpReportError) { | |
350 | - if (topUpReportError.indexOf('Invalid XML-RPC message') < 0) { | |
368 | + if (errorOnTopUpReport(topUpReportError)) { | |
351 | 369 | |
352 | - logger.warn('Error sending topUpReport retrying another url (if available): ' + topUpReportError, {error: topUpReportError}); | |
353 | - sendTopUpReport(reverseUrls, params, ++urlIdx, retry); | |
354 | - return; | |
370 | + logger.warn('Error sending topUpReport retrying another url (if available): ' + topUpReportError, {error: topUpReportError}); | |
371 | + sendTopUpReport(reverseUrls, params, ++urlIdx, retry); | |
372 | + return; | |
355 | 373 | |
356 | - } | |
357 | 374 | } |
358 | 375 | |
359 | 376 | logger.verbose("topUpReport ACK", {value: value}); |