Enum in io compiler

IoError

enum IoError
Import
use io::{IoError};
Source: compiler/src/builtin_docs/io.hy

The error type of every io, io::fs and io::net operation.

OS errors map to the closest variant; anything without one is Other. IoError implements Show (the variant name), so %v in format prints it.

Variants#

WouldBlock#

The operation is not ready yet and would have to wait; retry after wait_readable / wait_writable.

NotFound#

The file, directory or host was not found.

PermissionDenied#

The OS refused the operation.

AlreadyClosed#

The stream was already closed.

InvalidInput#

An argument was invalid: bad open mode, port out of range, bad UTF-8, wrong kind of stream, …

Other#

Any other OS error.

NotADirectory#

A path component is not a directory.

AlreadyExists#

The file or directory already exists.

TimedOut#

A deadline or OS timeout passed (distinct from WouldBlock).

Truncated#

The data ended early (the OS reported an unexpected end of file).

Certificate#

A TLS certificate was rejected (reported by attached packages such as coil-tls).

Handshake#

A TLS handshake failed (reported by attached packages such as coil-tls).

Examples#

use io::{open, IoError};
use string::{format};
use tests::assert;
let msg = match open("/tmp/coil_doc_no_such_dir/file.txt", "r") {
    Result::Ok(_) => "opened",
    Result::Err(IoError::NotFound) => "missing",
    Result::Err(_) => "other",
};
assert!(msg == "missing");
assert!(format("%v", IoError::TimedOut) == "TimedOut");

See also#

↑ ↓ navigate ↵ open