Search results

There are no results.

std.io.Error

class pub enum Error

An error type for I/O operations.

This type is typically constructed from raw OS error codes such as ENOENT on Unix systems. This enum doesn't define a variant for every possible error. Instead, we define a variant for the most commonly used errors, and represent other errors using the Other variant.

Constructors

AddressInUse

AddressInUse()

The address is already in use.

AddressUnavailable

AddressUnavailable()

The address isn't available.

AlreadyConnected

AlreadyConnected()

A connection is already established.

AlreadyExists

AlreadyExists()

A resource already exists.

BrokenPipe

BrokenPipe()

The operation failed because a pipe was closed.

ConnectionAborted

ConnectionAborted()

The connection was aborted by the remote server.

ConnectionRefused

ConnectionRefused()

The connection was refused by the remote server.

ConnectionReset

ConnectionReset()

The connection was reset by the remote server.

Deadlock

Deadlock()

An operation would result in a deadlock.

DirectoryNotEmpty

DirectoryNotEmpty()

A directory isn't empty.

FileTooLarge

FileTooLarge()

A file is too large.

HostUnreachable

HostUnreachable()

The remote host is unreachable.

InProgress

InProgress()

The operation is in progress.

Interrupted

Interrupted()

The operation was interrupted.

InvalidArgument

InvalidArgument()

One or more arguments are invalid.

InvalidFileName

InvalidFileName()

The file name is invalid.

InvalidSeek

InvalidSeek()

The seek operation is invalid.

IsADirectory

IsADirectory()

The resource is a directory.

NetworkDown

NetworkDown()

The network is down.

NetworkUnreachable

NetworkUnreachable()

The network is unreachable.

NotADirectory

NotADirectory()

The resource isn't a directory.

NotConnected

NotConnected()

A connection isn't established.

NotFound

NotFound()

The resource isn't found.

OutOfMemory

OutOfMemory()

The operation failed because not enough memory could be allocated.

PermissionDenied

PermissionDenied()

The operation failed because it lacked the necessary privileges.

ReadOnlyFilesystem

ReadOnlyFilesystem()

The filesystem is read-only.

ResourceBusy

ResourceBusy()

The resource is busy.

StorageFull

StorageFull()

The underlying storage is full.

TimedOut

TimedOut()

The operation timed out.

WouldBlock

WouldBlock()

The operation would block.

BadAddress

BadAddress()

A memory address used (e.g. as an argument) is in an invalid range.

Other

Other(Int)

An error not covered by the other variants.

The wrapped Int is the raw error code.

Static methods

from_os_error

Show source code
Hide source code
fn pub static from_os_error(code: Int) -> Error {
  match code {
    case errors.EPERM -> Error.PermissionDenied
    case errors.ENOENT -> Error.NotFound
    case errors.EINTR -> Error.Interrupted
    case errors.EAGAIN -> Error.WouldBlock
    case errors.ENOMEM -> Error.OutOfMemory
    case errors.EACCES -> Error.PermissionDenied
    case errors.EBUSY -> Error.ResourceBusy
    case errors.EEXIST -> Error.AlreadyExists
    case errors.ENOTDIR -> Error.NotADirectory
    case errors.EISDIR -> Error.IsADirectory
    case errors.EINVAL -> Error.InvalidArgument
    case errors.EFBIG -> Error.FileTooLarge
    case errors.ENOSPC -> Error.StorageFull
    case errors.ESPIPE -> Error.InvalidSeek
    case errors.EROFS -> Error.ReadOnlyFilesystem
    case errors.EPIPE -> Error.BrokenPipe
    case errors.EDEADLK -> Error.Deadlock
    case errors.ENAMETOOLONG -> Error.InvalidFileName
    case errors.ENOTEMPTY -> Error.DirectoryNotEmpty
    case errors.ETIME -> Error.TimedOut
    case errors.EADDRINUSE -> Error.AddressInUse
    case errors.EADDRNOTAVAIL -> Error.AddressUnavailable
    case errors.ENETDOWN -> Error.NetworkDown
    case errors.ENETUNREACH -> Error.NetworkUnreachable
    case errors.ECONNABORTED -> Error.ConnectionAborted
    case errors.ECONNRESET -> Error.ConnectionReset
    case errors.EISCONN -> Error.AlreadyConnected
    case errors.ENOTCONN -> Error.NotConnected
    case errors.ETIMEDOUT -> Error.TimedOut
    case errors.ECONNREFUSED -> Error.ConnectionRefused
    case errors.EHOSTUNREACH -> Error.HostUnreachable
    case errors.EINPROGRESS -> Error.InProgress
    case errors.EFAULT -> Error.BadAddress
    case val -> Error.Other(val)
  }
}
fn pub static from_os_error(code: Int) -> Error

Returns an Error from a raw OS error code.

Examples

import std.unix.errors (ENOENT)

Error.from_os_error(ENOENT) # => Error.NotFound

last_os_error

Show source code
Hide source code
fn pub static last_os_error -> Error {
  from_os_error(inko_last_error as Int)
}
fn pub static last_os_error -> Error

Returns the last OS error produced by the current OS thread.

Instance methods

!=

Show source code
Hide source code
fn pub !=(other: T) -> Bool {
  (self == other).false?
}
fn pub !=(other: T) -> Bool

Returns true if self and the given object are not equal to each other.

==

Show source code
Hide source code
fn pub ==(other: ref Error) -> Bool {
  match (self, other) {
    case (AddressInUse, AddressInUse) -> true
    case (AddressUnavailable, AddressUnavailable) -> true
    case (AlreadyConnected, AlreadyConnected) -> true
    case (AlreadyExists, AlreadyExists) -> true
    case (BrokenPipe, BrokenPipe) -> true
    case (ConnectionAborted, ConnectionAborted) -> true
    case (ConnectionRefused, ConnectionRefused) -> true
    case (ConnectionReset, ConnectionReset) -> true
    case (Deadlock, Deadlock) -> true
    case (DirectoryNotEmpty, DirectoryNotEmpty) -> true
    case (FileTooLarge, FileTooLarge) -> true
    case (HostUnreachable, HostUnreachable) -> true
    case (InProgress, InProgress) -> true
    case (Interrupted, Interrupted) -> true
    case (InvalidArgument, InvalidArgument) -> true
    case (InvalidFileName, InvalidFileName) -> true
    case (InvalidSeek, InvalidSeek) -> true
    case (IsADirectory, IsADirectory) -> true
    case (NetworkDown, NetworkDown) -> true
    case (NetworkUnreachable, NetworkUnreachable) -> true
    case (NotADirectory, NotADirectory) -> true
    case (NotConnected, NotConnected) -> true
    case (NotFound, NotFound) -> true
    case (OutOfMemory, OutOfMemory) -> true
    case (PermissionDenied, PermissionDenied) -> true
    case (ReadOnlyFilesystem, ReadOnlyFilesystem) -> true
    case (ResourceBusy, ResourceBusy) -> true
    case (StorageFull, StorageFull) -> true
    case (TimedOut, TimedOut) -> true
    case (WouldBlock, WouldBlock) -> true
    case (Other(a), Other(b)) -> a == b
    case _ -> false
  }
}
fn pub ==(other: ref Error) -> Bool

Returns true if self and the given object are equal to each other.

This operator is used to perform structural equality. This means two objects residing in different memory locations may be considered equal, provided their structure is equal. For example, two different arrays may be considered to have structural equality if they contain the exact same values.

fmt

Show source code
Hide source code
fn pub fmt(formatter: mut Formatter) {
  let name = match self {
    case AddressInUse -> 'AddressInUse'
    case AddressUnavailable -> 'AddressUnavailable'
    case AlreadyConnected -> 'AlreadyConnected'
    case AlreadyExists -> 'AlreadyExists'
    case BrokenPipe -> 'BrokenPipe'
    case ConnectionAborted -> 'ConnectionAborted'
    case ConnectionRefused -> 'ConnectionRefused'
    case ConnectionReset -> 'ConnectionReset'
    case Deadlock -> 'Deadlock'
    case DirectoryNotEmpty -> 'DirectoryNotEmpty'
    case FileTooLarge -> 'FileTooLarge'
    case HostUnreachable -> 'HostUnreachable'
    case InProgress -> 'InProgress'
    case Interrupted -> 'Interrupted'
    case InvalidArgument -> 'InvalidArgument'
    case InvalidFileName -> 'InvalidFileName'
    case InvalidSeek -> 'InvalidSeek'
    case IsADirectory -> 'IsADirectory'
    case NetworkDown -> 'NetworkDown'
    case NetworkUnreachable -> 'NetworkUnreachable'
    case NotADirectory -> 'NotADirectory'
    case NotConnected -> 'NotConnected'
    case NotFound -> 'NotFound'
    case OutOfMemory -> 'OutOfMemory'
    case PermissionDenied -> 'PermissionDenied'
    case ReadOnlyFilesystem -> 'ReadOnlyFilesystem'
    case ResourceBusy -> 'ResourceBusy'
    case StorageFull -> 'StorageFull'
    case TimedOut -> 'TimedOut'
    case WouldBlock -> 'WouldBlock'
    case BadAddress -> 'BadAddress'
    case Other(code) -> {
      formatter.tuple('Other').field(code).finish
      return
    }
  }

  formatter.tuple(name).finish
}
fn pub fmt(formatter: mut Formatter)

Formats self in a human-readable format for debugging purposes.

to_string

Show source code
Hide source code
fn pub to_string -> String {
  match self {
    case AddressInUse -> 'the address is already in use'
    case AddressUnavailable -> "the address isn't available"
    case AlreadyConnected -> 'the connection is already established'
    case AlreadyExists -> 'the resource already exists'
    case BrokenPipe -> 'the operation failed because a pipe was closed'
    case ConnectionAborted -> 'the connection was terminated by the server'
    case ConnectionRefused -> 'the connection was refused by the server'
    case ConnectionReset -> 'the connection was reset by the server'
    case Deadlock -> 'the resource would deadlock'
    case DirectoryNotEmpty -> "the directory isn't empty"
    case FileTooLarge -> 'the file is too large'
    case HostUnreachable -> 'the host is unreachable'
    case InProgress -> 'the operation is in progress'
    case Interrupted -> 'the operation was interrupted'
    case InvalidArgument -> 'one or more arguments are invalid'
    case InvalidFileName -> 'the file name is too long'
    case InvalidSeek -> 'the seek operation is invalid'
    case IsADirectory -> 'the resource is a directory'
    case NetworkDown -> 'the network is down'
    case NetworkUnreachable -> 'the network is unreachable'
    case NotADirectory -> "the resource isn't a directory"
    case NotConnected -> "a connection isn't established"
    case NotFound -> "the resource isn't found"
    case OutOfMemory -> 'we ran out of memory'
    case PermissionDenied -> 'the operation lacks the necessary privileges'
    case ReadOnlyFilesystem -> 'the file system is read-only'
    case ResourceBusy -> 'the resource is busy'
    case StorageFull -> 'the storage is full'
    case TimedOut -> 'the operation timed out'
    case WouldBlock -> 'the operation would block'
    case BadAddress -> 'a memory address is in an invalid range'
    case Other(code) -> 'an other error with code ${code} occurred'
  }
}
fn pub to_string -> String

Converts self to a String.

Implemented traits

std.cmp.

Equal

impl Equal[ref Error] for Error
std.fmt.

Format

impl Format for Error
std.string.

ToString

impl ToString for Error