Handle Shapeshift Error Messages (#811)

* Add error message if exists in shapeshift

* console error if shapeshiftOrderCreateFailed and bityOrderCreateFailed

* check e before checking e.message

* Handle preflight rejections. Put failure on any error.
This commit is contained in:
Eddie Wang 2018-01-15 01:09:38 -05:00 committed by Daniel Ternyak
parent fa8fbe531f
commit 9ee764be2e
2 changed files with 18 additions and 4 deletions

View File

@ -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() {

View File

@ -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());
}
}