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 constructor for every possible error. Instead, we define a constructor for the most commonly used errors, and represent other errors using the Other constructor.

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.

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.

InvalidData

InvalidData()

The data provided for the operation is invalid, such as when using an invalid TLS certificate or when a TLS socket encountered invalid TLS data (e.g. an invalid handshake message).

EndOfInput

EndOfInput()

The operation encountered the end of the input stream, but more input is required.

An example of where this error is encountered is when reading from a TLS socket that was closed without sending the close_notify message.

CrossDeviceLink()

A file couldn't be renamed, linked or copied because the operation takes places across different devices.

NotSupported

NotSupported()

The operation isn't supported.

Other

Other(Int)

An error not covered by the other constructor.

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 libc.EAGAIN -> Error.WouldBlock
    case libc.EPERM -> Error.PermissionDenied
    case libc.ENOENT -> Error.NotFound
    case libc.EINTR -> Error.Interrupted
    case libc.ENOMEM -> Error.OutOfMemory
    case libc.EACCES -> Error.PermissionDenied
    case libc.EBUSY -> Error.ResourceBusy
    case libc.EEXIST -> Error.AlreadyExists
    case libc.ENOTDIR -> Error.NotADirectory
    case libc.EISDIR -> Error.IsADirectory
    case libc.EINVAL -> Error.InvalidArgument
    case libc.EFBIG -> Error.FileTooLarge
    case libc.ENOSPC -> Error.StorageFull
    case libc.ESPIPE -> Error.InvalidSeek
    case libc.EROFS -> Error.ReadOnlyFilesystem
    case libc.EPIPE -> Error.BrokenPipe
    case libc.EDEADLK -> Error.Deadlock
    case libc.ENAMETOOLONG -> Error.InvalidFileName
    case libc.ENOTEMPTY -> Error.DirectoryNotEmpty
    case libc.ETIME -> Error.TimedOut
    case libc.EADDRINUSE -> Error.AddressInUse
    case libc.EADDRNOTAVAIL -> Error.AddressUnavailable
    case libc.ENETDOWN -> Error.NetworkDown
    case libc.ENETUNREACH -> Error.NetworkDown
    case libc.ECONNABORTED -> Error.ConnectionAborted
    case libc.ECONNRESET -> Error.ConnectionReset
    case libc.EISCONN -> Error.AlreadyConnected
    case libc.ENOTCONN -> Error.NotConnected
    case libc.ETIMEDOUT -> Error.TimedOut
    case libc.ECONNREFUSED -> Error.ConnectionRefused
    case libc.EHOSTUNREACH -> Error.HostUnreachable
    case libc.EINPROGRESS -> Error.InProgress
    case libc.EFAULT -> Error.BadAddress
    case libc.EXDEV -> Error.CrossDeviceLink
    case libc.ENOTSUP or libc.EOPNOTSUPP -> Error.NotSupported
    case INVALID_DATA -> Error.InvalidData
    case UNEXPECTED_EOF -> Error.EndOfInput
    case val -> Error.Other(val)
  }
}
fn pub static from_os_error(code: Int) -> Error

Returns an Error from a raw OS error code.

last_os_error

Show source code
Hide source code
fn pub static last_os_error -> Error {
  from_os_error(libc.errno)
}
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 (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 (InvalidData, InvalidData) -> true
    case (EndOfInput, EndOfInput) -> true
    case (CrossDeviceLink, CrossDeviceLink) -> true
    case (NotSupported, NotSupported) -> true
    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 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 InvalidData -> 'InvalidData'
    case EndOfInput -> 'EndOfInput'
    case CrossDeviceLink -> 'CrossDeviceLink'
    case NotSupported -> 'NotSupported'
    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 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 InvalidData -> "the data provided isn't valid for the operation"
    case CrossDeviceLink -> {
      "the operation failed because it can't be performed across devices"
    }
    case EndOfInput -> {
      'the end of the input stream is reached, but more input is required'
    }
    case NotSupported -> "the operation isn't supported"
    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