You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The standard InvalidOperationException is, according to the docs:
used in cases when the failure to invoke a method is caused by reasons other than invalid arguments
However, it is apparently thrown in cases where the lease name is bad.
At least, that's what the docs and comments say. The code does this when we get a 400 error from Azure Storage, and as far as I can see from the Storage REST API docs, you only get those in a handful of scenarios, none of them apparently having anything to do with bad names, but perhaps the REST API docs are wrong.
In any case there are a few problems with this. First, since this library is supposed to present an abstraction with a pluggable underlying implementation, our abstraction should define what is and is not a valid name, rather than leaving it to the underlying implementation, possibly transforming invalid names into valid ones. Second, since the error this is supposed to indicate is indicative of bad arguments, we should use one of the argument exception types.
The basic idea of InvalidOperationException is to indicate that there wasn't anything wrong with the arguments per se, just that the operation being attempted can't be done right now because of the object's state. (E.g., ObjectDisposedException derives from InvalidOperationException, because it's exactly this pattern: attempting to perform any operation that would normally be allowed is generally not allowed once an object is in a disposed state.)
The text was updated successfully, but these errors were encountered:
The standard
InvalidOperationException
is, according to the docs:However, it is apparently thrown in cases where the lease name is bad.
At least, that's what the docs and comments say. The code does this when we get a 400 error from Azure Storage, and as far as I can see from the Storage REST API docs, you only get those in a handful of scenarios, none of them apparently having anything to do with bad names, but perhaps the REST API docs are wrong.
In any case there are a few problems with this. First, since this library is supposed to present an abstraction with a pluggable underlying implementation, our abstraction should define what is and is not a valid name, rather than leaving it to the underlying implementation, possibly transforming invalid names into valid ones. Second, since the error this is supposed to indicate is indicative of bad arguments, we should use one of the argument exception types.
The basic idea of
InvalidOperationException
is to indicate that there wasn't anything wrong with the arguments per se, just that the operation being attempted can't be done right now because of the object's state. (E.g.,ObjectDisposedException
derives fromInvalidOperationException
, because it's exactly this pattern: attempting to perform any operation that would normally be allowed is generally not allowed once an object is in a disposed state.)The text was updated successfully, but these errors were encountered: