Implemented a dedicated error handler for tasks