Skip to content

Commit

Permalink
refactor: Handle errors when importing collections (#2455)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjai0py committed Jun 17, 2024
1 parent 693f882 commit 5c04f88
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
15 changes: 11 additions & 4 deletions packages/bruno-app/src/components/Sidebar/TitleBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ const TitleBar = () => {
};

const handleImportCollectionLocation = (collectionLocation) => {
dispatch(importCollection(importedCollection, collectionLocation));
setImportCollectionLocationModalOpen(false);
setImportedCollection(null);
toast.success('Collection imported successfully');
dispatch(importCollection(importedCollection, collectionLocation))
.then(() => {
setImportCollectionLocationModalOpen(false);
setImportedCollection(null);
toast.success('Collection imported successfully');
})
.catch((err) => {
setImportCollectionLocationModalOpen(false);
console.error(err);
toast.error('An error occurred while importing the collection. Check the logs for more information.');
});
};

const menuDropdownTippyRef = useRef();
Expand Down
15 changes: 11 additions & 4 deletions packages/bruno-app/src/components/Welcome/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ const Welcome = () => {
};

const handleImportCollectionLocation = (collectionLocation) => {
dispatch(importCollection(importedCollection, collectionLocation));
setImportCollectionLocationModalOpen(false);
setImportedCollection(null);
toast.success('Collection imported successfully');
dispatch(importCollection(importedCollection, collectionLocation))
.then(() => {
setImportCollectionLocationModalOpen(false);
setImportedCollection(null);
toast.success('Collection imported successfully');
})
.catch((err) => {
setImportCollectionLocationModalOpen(false);
console.error(err);
toast.error('An error occurred while importing the collection. Check the logs for more information.');
});
};

return (
Expand Down

0 comments on commit 5c04f88

Please sign in to comment.