mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-23 15:19:01 +01:00
Merge pull request #471 from therealrinku/two
showing error response in response tab instead of alert message
This commit is contained in:
commit
6c3dc7bbd2
@ -11,7 +11,7 @@ import StyledWrapper from './StyledWrapper';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
const QueryResult = ({ item, collection, data, width, disableRunEventListener, headers }) => {
|
const QueryResult = ({ item, collection, data, width, disableRunEventListener, headers, error }) => {
|
||||||
const { storedTheme } = useTheme();
|
const { storedTheme } = useTheme();
|
||||||
const [tab, setTab] = useState('preview');
|
const [tab, setTab] = useState('preview');
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@ -119,7 +119,7 @@ const QueryResult = ({ item, collection, data, width, disableRunEventListener, h
|
|||||||
<div className="flex justify-end gap-2 text-xs" role="tablist">
|
<div className="flex justify-end gap-2 text-xs" role="tablist">
|
||||||
{getTabs()}
|
{getTabs()}
|
||||||
</div>
|
</div>
|
||||||
{activeResult}
|
{error ? <span className="text-red-500">{error}</span> : activeResult}
|
||||||
</StyledWrapper>
|
</StyledWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -42,6 +42,7 @@ const ResponsePane = ({ rightPaneWidth, item, collection }) => {
|
|||||||
width={rightPaneWidth}
|
width={rightPaneWidth}
|
||||||
data={response.data}
|
data={response.data}
|
||||||
headers={response.headers}
|
headers={response.headers}
|
||||||
|
error={response.error}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -142,22 +142,28 @@ export const sendRequest = (item, collectionUid) => (dispatch, getState) => {
|
|||||||
})
|
})
|
||||||
.then(resolve)
|
.then(resolve)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
dispatch(
|
|
||||||
responseReceived({
|
|
||||||
itemUid: item.uid,
|
|
||||||
collectionUid: collectionUid,
|
|
||||||
response: null
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
if (err && err.message === "Error invoking remote method 'send-http-request': Error: Request cancelled") {
|
if (err && err.message === "Error invoking remote method 'send-http-request': Error: Request cancelled") {
|
||||||
console.log('>> request cancelled');
|
console.log('>> request cancelled');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('>> sending request failed');
|
const errorMessage = err.message ?? 'Something went wrong';
|
||||||
console.log(err);
|
|
||||||
toast.error(err ? 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: errorResponse
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user