Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
fix: show errors of failed requests (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 authored Feb 15, 2019
1 parent 4688e12 commit 4a46bd3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
12 changes: 8 additions & 4 deletions src/views/refund/refundActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ export const startRefund = (
);
})
.catch(error => {
window.alert('Failed to refund swap');
dispatch(refundResponse(false, error.data));
const message = error.response.data.error;

window.alert(`Failed to refund swap: ${message}`);
dispatch(refundResponse(false, message));
});
};
};
Expand All @@ -131,8 +133,10 @@ const broadcastRefund = (currency, refundTransaction, cb) => {
})
.then(() => cb())
.catch(error => {
window.alert(`Failed to broadcast refund transaction`);
dispatch(refundResponse(false, error.data));
const message = error.response.data.error;

window.alert(`Failed to broadcast refund transaction: ${message}`);
dispatch(refundResponse(false, message));
});
};
};
4 changes: 3 additions & 1 deletion src/views/reverse/reverse.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ const ReverseSwap = ({
loadingText={swapStatus}
loadingRender={() => <Loading />}
onPress={() => {
startReverseSwap(swapInfo, props.nextStage);
if (swapInfo.address && swapInfo.address !== '') {
startReverseSwap(swapInfo, props.nextStage);
}
}}
/>
)}
Expand Down
7 changes: 4 additions & 3 deletions src/views/reverse/reverseActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ export const startReverseSwap = (swapInfo, nextStage) => {
startListening(dispatch, swapInfo, response.data, nextStage);
})
.catch(error => {
window.alert('Failed to execute swap');
console.log(error);
dispatch(reverseSwapResponse(false, error.data));
const message = error.response.data.error;

window.alert(`Failed to execute reverse swap: ${message}`);
dispatch(reverseSwapResponse(false, message));
});
};
};
Expand Down
6 changes: 4 additions & 2 deletions src/views/swap/swapActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ export const startSwap = (swapInfo, cb) => {
cb();
})
.catch(error => {
window.alert('Failed to execute swap');
dispatch(swapResponse(false, error.data));
const message = error.response.data.error;

window.alert(`Failed to execute swap: ${message}`);
dispatch(swapResponse(false, message));
});
};
};
Expand Down

0 comments on commit 4a46bd3

Please sign in to comment.