diff --git a/dissect/extfs/exceptions.py b/dissect/extfs/exceptions.py index 734b1f1..1b34e2c 100644 --- a/dissect/extfs/exceptions.py +++ b/dissect/extfs/exceptions.py @@ -2,11 +2,15 @@ class Error(Exception): pass -class FileNotFoundError(Error): +class FileNotFoundError(Error, FileNotFoundError): pass -class NotADirectoryError(Error): +class IsADirectoryError(Error, IsADirectoryError): + pass + + +class NotADirectoryError(Error, NotADirectoryError): pass diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py new file mode 100644 index 0000000..6c5fe36 --- /dev/null +++ b/tests/test_exceptions.py @@ -0,0 +1,19 @@ +import pytest + +from dissect.extfs import exceptions + + +@pytest.mark.parametrize( + "exc, std", + [ + (exceptions.FileNotFoundError, FileNotFoundError), + (exceptions.IsADirectoryError, IsADirectoryError), + (exceptions.NotADirectoryError, NotADirectoryError), + ], +) +def test_filesystem_error_subclass(exc: exceptions.Error, std: Exception) -> None: + assert issubclass(exc, std) + assert isinstance(exc(), std) + + with pytest.raises(std): + raise exc()