MartinMalinda / vue-concurrency

A library for encapsulating asynchronous operations and managing concurrency for Vue and Composition API.
https://vue-concurrency.netlify.app/
MIT License
350 stars 15 forks source link

[Feature Request] Option to not catch errors #50

Open dospunk opened 3 years ago

dospunk commented 3 years ago

For projects with a global error handler the current system introduces boilerplate that would not be necessary if there were an option to not catch errors at all

MartinMalinda commented 2 years ago

The task definitely has to break execution on error. But it could definitely always pass the error upfront (rethrow). I was also thinking about some global hook for errors for the entire vue-concurrency. There you could also just rethrow yourself or do whatever else (console.error, report error etc).

But so far the usage of tasks is like this:

import { useTask } from 'vue-concurrency';

I'm not sure if it's possible to do something like this:

import { configureTasks } from 'vue-concurrency';

configureTasks({
  onError: (error) => {
    // your global on error handling goes here
   }
}); 

This setting would have to persist somehow. Maybe if it was assigned to to some variable in the module context it would be fine... I'll try 🙏