Closed RoryDungan closed 6 years ago
I suggest we call it PromiseStateException
, thrown whenever the state of the promise is invalid for the current operation (like resolve twice, resolve when rejected etc.) that inherits from an abstract PromiseException
class. This covers most if not all of the cases, and we have a base class we can inherit from for other types of exceptions.
Race
should probably just throw a ArgumentOutOfRangeException
instead.
I like the sound of that. In future if we need to add more types of exception they could also inherit from PromiseException.
Fixed in v3.0.0
The Microsoft guidelines recommend against throwing ApplicationException, and throwing a custom type of exception would make it easier for users to distinguish between exceptions thrown by the library and their own code.
So far the only places where this would change anything is where we are attempting to resolve/reject a promise in an invalid state and when Race is called with no promises. If we merge #65 this will add one more case (where progress is updated on an already resolved/rejected promise).