csv-to-sql-insert icon indicating copy to clipboard operation
csv-to-sql-insert copied to clipboard

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

Open shreyash2503 opened this issue 1 year ago • 0 comments

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<T>) 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.

shreyash2503 avatar Dec 23 '23 05:12 shreyash2503