Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Utility Function "catchAsync" for Simplified Error Handling in Asynchronous Operations #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shreyash2503
Copy link

Description:

Added a utility function catchAsync to handle asynchronous operations without redundant try-catch blocks. The function simplifies error handling for asynchronous functions returning promises.

Functionality:

The "catchAsync" function takes an asynchronous function that returns a promise (fn: AsyncCallback) and wraps it with a catch handler. It abstracts away the need for explicit try-catch blocks in every asynchronous function.

Usage:

Accepts an asynchronous function (fn) returning a promise.
Wraps the function call with a catch block to handle any promise rejections.
Provides a cleaner way to handle errors for asynchronous operations by logging them to the console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants