diff --git a/src/js/services/shapeShiftApiService.js b/src/js/services/shapeShiftApiService.js index 92564464a..67e6f23de 100644 --- a/src/js/services/shapeShiftApiService.js +++ b/src/js/services/shapeShiftApiService.js @@ -23,15 +23,17 @@ var ShapeShift = (function() { if (xmlhttp.status == 200) { var parsedResponse = JP(xmlhttp.responseText); cb.apply(null, [parsedResponse]); - } else if (xmlhttp.status === 500) { - var parsedResponse = JP(xmlhttp.responseText); - if (typeof parsedResponse.error === 'string') { - cb.apply(null, [parsedResponse]); - } else { - cb.apply(null, [new Error('Request Failed')]); - } } else { - cb.apply(null, [new Error('Request Failed')]) + var cbResponse = new Error('Request Failed'); + if (xmlhttp.status === 500) { + try { + var errorResponse = JSON.parse(xmlhttp.responseText); + if (typeof errorResponse.error === 'string') { + cbResponse = errorResponse; + } + } catch (e) { /* nop */ } + } + cb.apply(null, [cbResponse]); } } };