From stackoverflow.com:
Taken from MSDN's page on InvalidOperationException: "InvalidOperationException is used in cases when the failure to invoke a method is caused by reasons other than invalid arguments."
– STWCommented Apr 21, 2009 at 19:44
I often forget what the "right" exception is to throw when it's not an argument issue -- and linters are getting better at reminding me not to be lazy and to stop using Exception
with no subtype. "Code is evidence of the beliefs of its authors" after all.
I suppose InvalidOperationException
is as good a fallback as any.