Repository navigation
Pin the exceptions thrown for null, malformed and missing table paths - #343
Merged
Merged
Conversation
Since #342 the table path is resolved with Path.GetFullPath before the existence check, so a null path throws ArgumentNullException and an empty path or one containing a NUL character throws ArgumentException. Previously all three were reported as FileNotFoundException. The new exceptions match File.OpenRead and FileStream and describe the problem better, so the tests now state them as the intended behaviour. A path to a file that does not exist still throws FileNotFoundException. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why
#342 resolves the table path with
Path.GetFullPathbefore checking that the file exists.Path.GetFullPaththrows for inputs whereFile.Existsonly returned false, so the exception for an unusable path changed without being called out in that pull request:DbfTable/DbfDataReadernullFileNotFoundExceptionArgumentNullException(ParamNameispath)""FileNotFoundExceptionArgumentExceptionFileNotFoundExceptionArgumentExceptionFileNotFoundExceptionFileNotFoundExceptionThe new exceptions are the ones
File.OpenReadandFileStreamthrow for the same inputs, and they describe the problem better than "file not found" does for a null path. This pull request keeps them and makes them intentional.Changes
Tests only: three tests in
DbfTableTestsstate the exception for each case above. No library code changes.Compatibility
Code that catches
FileNotFoundExceptionto handle a null or empty path will now see an argument exception instead. This will go in the compatibility notes for v2.3.2.Testing
dotnet test -c Release: 539 passed, 1 skipped (already skipped on main).🤖 Generated with Claude Code