How to use the built-in InvalidStateException

It is up to you when to throw it, one should match the words in the exception to the kind of error. The arguments are again, situation dependent and are most likely literals.

Here’s an example from the wild

Which if we trace back to where it is thrown

and here’s the documentation for that call

https://docs.julialang.org/en/v1/base/parallel/#Base.take!-Tuple{Channel}

What seems to be different in Julia is the docs don’t mention that take! might throw and we have no way of annotating that. Meaning one day you might log in to find you didn’t use try in your long running code and you can make a sad face.

2 Likes