What is the best method for distinguishing between two exceptions of the same type, but thrown for various reasons.
For example, an InvalidOperationException may be InvalidOperationException while trying to access an empty sequence, but it can also be used when using a Concurrent object (e.g. BlockingCollection )
From my reading, I came to the conclusion that using BlockingCollection.CompleteAdding() to complete the signal is fine, and as such you would need to correctly catch the Exception and the handle (for example, exit the task)
What is the best way to filter them without using message content?
Edit: Both of them have the same HResult value.
source share