corvus-dotnet / corvus-dotnet/Corvus.Leasing

Throws InvalidOperationException due to bad input

Open
#90 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
3
Forks
1
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.