-
Type: Improvement
-
Resolution: Won't Do
-
Priority: Minor - P4
-
None
-
Affects Version/s: 3.0.5
-
Component/s: Native, Operations Layer
-
Empty show more show less
-
Not Needed
We have inconsistent behavior in how we handle errors in asynchronous functions.
Ideally, we should have the following behavior:
- Any error that occurs outside of an executeOperation call should be thrown, as we are still in synchronous boilerplate. This makes handling simple validation errors easier.
- Any errors that occur within an executeOperation call should be passed into the callback (and by extension either call a callback with an error or reject the promise).
We currently have behavior all over the place. Some examples:
- Collection.prototype.insertMany does async errors outside of executeOperation
- Collection.prototype.bulkWrite throws an error outside of executeOperation
- Collection.prototype.rename throws an error inside the executeOperation
We should have a consistent approach to this sort of stuff.