diff --git a/common/api/shapeshift.ts b/common/api/shapeshift.ts index f24ccd6f..9ca6f9bf 100644 --- a/common/api/shapeshift.ts +++ b/common/api/shapeshift.ts @@ -53,7 +53,15 @@ class ShapeshiftService { headers: new Headers(this.postHeaders) }) .then(checkHttpStatus) - .then(parseJSON); + .then(parseJSON) + .catch(err => { + // CORS rejection, meaning metamask don't want us + if (err.name === 'TypeError') { + throw new Error( + 'Shapeshift has blocked this request, visit shapeshift.io for more information or contact support' + ); + } + }); } public getCoins() { diff --git a/common/sagas/swap/orders.ts b/common/sagas/swap/orders.ts index 3a4d4843..01704ad6 100644 --- a/common/sagas/swap/orders.ts +++ b/common/sagas/swap/orders.ts @@ -156,6 +156,7 @@ export function* postBityOrderCreate(action: BityOrderCreateRequestedSwapAction) } catch (e) { const message = 'Connection Error. Please check the developer console for more details and/or contact support'; + console.error(e); yield put(showNotification('danger', message, TEN_SECONDS)); yield put(bityOrderCreateFailedSwap()); } @@ -185,9 +186,14 @@ export function* postShapeshiftOrderCreate( yield put(startPollShapeshiftOrderStatus()); } } catch (e) { - const message = - 'Connection Error. Please check the developer console for more details and/or contact support'; - yield put(showNotification('danger', message, TEN_SECONDS)); + if (e && e.message) { + yield put(showNotification('danger', e.message, TEN_SECONDS)); + } else { + const message = + 'Connection Error. Please check the developer console for more details and/or contact support'; + console.error(e); + yield put(showNotification('danger', message, TEN_SECONDS)); + } yield put(shapeshiftOrderCreateFailedSwap()); } }