From fdca86ffd2fe6c13f5f845372b37606ae87bb7cd Mon Sep 17 00:00:00 2001 From: therealrinku Date: Mon, 9 Oct 2023 12:33:10 +0545 Subject: [PATCH] showing error response in response tab instead of alert message --- .../ResponsePane/Overlay/StyledWrapper.js | 2 +- .../src/components/ResponsePane/index.js | 9 ++++++-- .../ReduxStore/slices/collections/actions.js | 21 ++++++++++--------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/packages/bruno-app/src/components/ResponsePane/Overlay/StyledWrapper.js b/packages/bruno-app/src/components/ResponsePane/Overlay/StyledWrapper.js index 68779c3c2..02ec6f4f7 100644 --- a/packages/bruno-app/src/components/ResponsePane/Overlay/StyledWrapper.js +++ b/packages/bruno-app/src/components/ResponsePane/Overlay/StyledWrapper.js @@ -3,7 +3,7 @@ import styled from 'styled-components'; const StyledWrapper = styled.div` position: absolute; z-index: 1; - height: 100vh; + height: 75vh; background-color: ${(props) => props.theme.requestTabPanel.responseOverlayBg}; div.overlay { diff --git a/packages/bruno-app/src/components/ResponsePane/index.js b/packages/bruno-app/src/components/ResponsePane/index.js index e38538145..81e0805c2 100644 --- a/packages/bruno-app/src/components/ResponsePane/index.js +++ b/packages/bruno-app/src/components/ResponsePane/index.js @@ -116,8 +116,13 @@ const ResponsePane = ({ rightPaneWidth, item, collection }) => { ) : null}
- {isLoading ? : null} - {getTabPanel(focusedTab.responsePaneTab)} + {isLoading && } + + {response.isError ? ( + {response.error} + ) : ( + getTabPanel(focusedTab.responsePaneTab) + )}
); diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js index 42b8318ac..5cc3870dd 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -117,22 +117,23 @@ export const sendRequest = (item, collectionUid) => (dispatch, getState) => { }) .then(resolve) .catch((err) => { + const errorMessage = err.message ?? 'Something went wrong'; + + const errorResponse = { + status: 'Error', + isError: true, + error: errorMessage, + size: '0', + duration: '0' + }; + dispatch( responseReceived({ itemUid: item.uid, collectionUid: collectionUid, - response: null + response: errorResponse }) ); - - if (err && err.message === "Error invoking remote method 'send-http-request': Error: Request cancelled") { - console.log('>> request cancelled'); - return; - } - - console.log('>> sending request failed'); - console.log(err); - toast.error(err ? err.message : 'Something went wrong!'); }); }); };