toIOException

fun Throwable.toIOException(): IOException(source)

Converts the throwable to an IOException if it is not already one. When errorCodeOrNull is ENOENT, then this function will return FileNotFoundException. When the errorCodeOrNull is EINTR, then this function will return InterruptedIOException. When the errorCodeOrNull starts with ERR_FS_, then this function will return FileSystemException.


fun Throwable.toIOException(file: File?, other: File? = null): IOException(source)

Converts the throwable to an IOException if it is not already one. When errorCodeOrNull is ENOENT, then this function will return FileNotFoundException. When the errorCodeOrNull is EINTR, then this function will return InterruptedIOException. When the errorCodeOrNull starts with ERR_FS_, then this function will return FileSystemException.

If the file parameter is non-null, an appropriate FileSystemException will be returned for the given errorCodeOrNull.

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.