Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throws InvalidOperationException due to bad input #90

Open
idg10 opened this issue Feb 27, 2020 · 0 comments
Open

Throws InvalidOperationException due to bad input #90

idg10 opened this issue Feb 27, 2020 · 0 comments

Comments

@idg10
Copy link
Contributor

idg10 commented Feb 27, 2020

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant