lastErrorToIOException

inline fun lastErrorToIOException(lastError: <Error class: unknown class> = GetLastError()): IOException(source)

Retrieves the human-readable message for GetLastError via FormatMessageA and returns it as an IOException. When the last error is ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, then this function will return FileNotFoundException. When the last error is ERROR_OPERATION_ABORTED, then this function will return InterruptedIOException. When the last error is ERROR_HANDLE_EOF, then this function returns EOFException.

Return

The formatted error as an IOException

See also


fun lastErrorToIOException(file: File?, other: File? = null, lastError: <Error class: unknown class> = GetLastError()): IOException(source)

Retrieves the human-readable message for GetLastError via FormatMessageA and returns it as an IOException. When the last error is ERROR_FILE_NOT_FOUND or ERROR_PATH_NOT_FOUND, then this function will return FileNotFoundException.

If and only if the file parameter is non-null, an appropriate FileSystemException will be returned for the given last error.

Return

The formatted error as an IOException

Parameters

file

The File (if any) to associate this error with a FileSystemException

other

If multiple files were involved, such as a copy operation.

See also