diff --git a/packages/bruno-app/src/components/CreateTransientRequest/index.js b/packages/bruno-app/src/components/CreateTransientRequest/index.js index 9a98985e0..43355837c 100644 --- a/packages/bruno-app/src/components/CreateTransientRequest/index.js +++ b/packages/bruno-app/src/components/CreateTransientRequest/index.js @@ -9,6 +9,7 @@ import { useDispatch, useSelector } from 'react-redux'; import { flattenItems, isItemARequest, isItemTransientRequest } from 'utils/collections'; import filter from 'lodash/filter'; import { get } from 'lodash'; +import { formatIpcError } from 'utils/common/error'; const REQUEST_TYPE = { HTTP: 'http', @@ -103,7 +104,7 @@ const CreateTransientRequest = ({ collectionUid }) => { itemUid: null, isTransient: true }) - ).catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request')); + ).catch((err) => toast.error(formatIpcError(err) || 'An error occurred while adding the request')); }, [dispatch, collection, collectionPresets.requestUrl]); const handleCreateGraphQLRequest = useCallback(() => { @@ -130,7 +131,7 @@ const CreateTransientRequest = ({ collectionUid }) => { } } }) - ).catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request')); + ).catch((err) => toast.error(formatIpcError(err) || 'An error occurred while adding the request')); }, [dispatch, collection, collectionPresets.requestUrl]); const handleCreateWebSocketRequest = useCallback(() => { @@ -149,7 +150,7 @@ const CreateTransientRequest = ({ collectionUid }) => { itemUid: null, isTransient: true }) - ).catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request')); + ).catch((err) => toast.error(formatIpcError(err) || 'An error occurred while adding the request')); }, [dispatch, collection, collectionPresets.requestUrl]); const handleCreateGrpcRequest = useCallback(() => { @@ -167,7 +168,7 @@ const CreateTransientRequest = ({ collectionUid }) => { itemUid: null, isTransient: true }) - ).catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request')); + ).catch((err) => toast.error(formatIpcError(err) || 'An error occurred while adding the request')); }, [dispatch, collection, collectionPresets.requestUrl]); const handleItemClick = (type) => { diff --git a/packages/bruno-app/src/components/SaveTransientRequest/index.js b/packages/bruno-app/src/components/SaveTransientRequest/index.js index c8569f735..772876dbe 100644 --- a/packages/bruno-app/src/components/SaveTransientRequest/index.js +++ b/packages/bruno-app/src/components/SaveTransientRequest/index.js @@ -15,6 +15,7 @@ import { resolveRequestFilename } from 'utils/common/platform'; import { transformRequestToSaveToFilesystem, findCollectionByUid, findItemInCollection } from 'utils/collections'; import { DEFAULT_COLLECTION_FORMAT } from 'utils/common/constants'; import { itemSchema } from '@usebruno/schema'; +import { formatIpcError } from 'utils/common/error'; const SaveTransientRequest = ({ item: itemProp, collection: collectionProp, isOpen = false, onClose }) => { const dispatch = useDispatch(); @@ -139,7 +140,7 @@ const SaveTransientRequest = ({ item: itemProp, collection: collectionProp, isOp toast.success('Request saved successfully'); handleClose(); } catch (err) { - toast.error(err?.message || 'Failed to save request'); + toast.error(formatIpcError(err) || 'Failed to save request'); console.error('Error saving request:', err); } };