Class FileNotFoundError
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
Python's FileNotFoundError (errno ENOENT, 2): a file or directory that does not exist. NumSharp's
file functions raise it as CPython's open() does: np.load / np.fromfile / np.save into
a missing directory read [Errno 2] No such file or directory: 'x.npy', and np.loadtxt's
DataSource raises x.txt not found. (its own text, without an errno).
public class FileNotFoundError : OSError, ISerializable, INumSharpException
- Inheritance
-
FileNotFoundError
- Implements
- Inherited Members
Remarks
A subclass of OSError and so of .NET's IOException. Footgun: it is NOT .NET's
FileNotFoundException, which a catch (FileNotFoundException) written for older
NumSharp expects; catch FileNotFoundError, or IOException for both. The
.NET exception behind it is its InnerException (with the full path .NET resolved).
Constructors
FileNotFoundError()
Creates the error with Python's text for a bare raise OSError: an empty
Message, as str(OSError()) is '' (not .NET's
IOException default, "I/O error occurred."); every attribute is null.
public FileNotFoundError()
Remarks
ToString() then starts with the class name alone, as Python's traceback prints a
bare OSError; prefer a message that names the file and the operation.
FileNotFoundError(int?, string)
Python's OSError(errno, strerror): the message is CPython's [Errno 2] No such file or
directory.
public FileNotFoundError(int? errno, string strerror)
Parameters
errnoint?The operating system's error number, or null for
None.strerrorstringIts text (
strerror(errno)), or null forNone.
Remarks
Builds THIS class whatever the errno; Create(int?, string) picks the subclass the errno names, as Python's call does.
FileNotFoundError(int?, string, string)
Python's OSError(errno, strerror, filename): the message is CPython's [Errno 2] No such file or
directory: 'x.npy', the file name as Python's repr() quotes it.
public FileNotFoundError(int? errno, string strerror, string filename)
Parameters
errnoint?The operating system's error number, or null for
None.strerrorstringIts text, or null for
None.filenamestringThe file the operation was on, or null for none (the message then omits it).
FileNotFoundError(int?, string, string, int?)
Python's OSError(errno, strerror, filename, winerror): on Windows, winerror (a Windows
error code, or an HRESULT carrying one) decides errno through CPython's
winerror_to_errno, and the message reads [WinError 5] Access is denied: 'f'.
public FileNotFoundError(int? errno, string strerror, string filename, int? winerror)
Parameters
errnoint?The error number, or null for
None; replaced on Windows whenwinerroris given.strerrorstringIts text, or null for
None.filenamestringThe file the operation was on, or null for none.
winerrorint?The Windows error code, or null for
None.
Remarks
Footgun, CPython's own: on Windows a four- or five-argument call prints [WinError None] even when
winerror is null; elsewhere winerror is ignored (CPython parses it and
drops it) and winerror stays null.
FileNotFoundError(int?, string, string, int?, string)
Python's OSError(errno, strerror, filename, winerror, filename2): an operation on two files, the message
naming both ([Errno 17] File exists: 'a' -> 'b'; on Windows [WinError …]).
public FileNotFoundError(int? errno, string strerror, string filename, int? winerror, string filename2)
Parameters
errnoint?The error number, or null for
None.strerrorstringIts text, or null for
None.filenamestringThe first file, or null for none (the second is then dropped, as in CPython).
winerrorint?The Windows error code, or null for
None(see the four-argument form).filename2stringThe second file, or null for none.
FileNotFoundError(string)
Creates the error with NumPy's message text; every attribute is null, as for Python's
OSError('message').
public FileNotFoundError(string message)
Parameters
messagestringThe verbatim message (
cannot write object arrays to a file in binary mode).
FileNotFoundError(string, Exception)
Creates the error with NumPy's message text and the exception that caused it; every attribute is null.
public FileNotFoundError(string message, Exception innerException)