module Errno
When an operating system encounters an error, it typically reports the error as an integer error code:
$ ls nosuch.txt ls: cannot access 'nosuch.txt': No such file or directory $ echo $? # Code for last error. 2
When the Ruby interpreter interacts with the operating system and receives such an error code (e.g., 2), it maps the code to a particular Ruby exception class (e.g., Errno::ENOENT):
File.open('nosuch.txt') # => No such file or directory @ rb_sysopen - nosuch.txt (Errno::ENOENT)
Each such class is:
-
A nested class in this module,
Errno. -
A subclass of class
SystemCallError. -
Associated with an error code.
Thus:
Errno::ENOENT.superclass # => SystemCallError Errno::ENOENT::Errno # => 2
The names of nested classes are returned by method Errno.constants:
Errno.constants.size # => 158 Errno.constants.sort.take(5) # => [:E2BIG, :EACCES, :EADDRINUSE, :EADDRNOTAVAIL, :EADV]
As seen above, the error code associated with each class is available as the value of a constant; the value for a particular class may vary among operating systems. If the class is not needed for the particular operating system, the value is zero:
Errno::ENOENT::Errno # => 2 Errno::ENOTCAPABLE::Errno # => 0
Each class in Errno can be created with optional messages:
Errno::EPIPE.new # => #<Errno::EPIPE: Broken pipe> Errno::EPIPE.new("foo") # => #<Errno::EPIPE: Broken pipe - foo> Errno::EPIPE.new("foo", "here") # => #<Errno::EPIPE: Broken pipe @ here - foo>
See SystemCallError.new.
Constants
- E2BIG
-
âArgument list too longâ error
- EACCES
-
âPermission deniedâ error
- EADDRINUSE
-
âAddress already in useâ error
- EADDRNOTAVAIL
-
âAddress not availableâ error
- EADV
-
âAdvertise errorâ error
- EAFNOSUPPORT
-
âAddress family not supportedâ error
- EAGAIN
-
âResource temporarily unavailable, try again (may be the same value as
EWOULDBLOCK)â error - EALREADY
-
âConnection already in progressâ error
- EAUTH
-
âAuthentication errorâ error
- EBADARCH
-
âBad CPU type in executableâ error
- EBADE
-
âBad exchangeâ error
- EBADEXEC
-
âBad executableâ error
- EBADF
-
âBad file descriptorâ error
- EBADFD
-
âFile descriptor in bad stateâ error
- EBADMACHO
-
âMalformed Macho fileâ error
- EBADMSG
-
âBad messageâ error
- EBADR
-
âInvalid request descriptorâ error
- EBADRPC
-
âRPC struct is badâ error
- EBADRQC
-
âInvalid request codeâ error
- EBADSLT
-
âInvalid slotâ error
- EBFONT
-
âBad font file formatâ error
- EBUSY
-
âDevice or resource busyâ error
- ECANCELED
-
âOperation canceledâ error
- ECAPMODE
-
âNot permitted in capability modeâ error
- ECHILD
-
âNo child processesâ error
- ECHRNG
-
âChannel number out of rangeâ error
- ECOMM
-
âCommunication error on sendâ error
- ECONNABORTED
-
âConnection abortedâ error
- ECONNREFUSED
-
âConnection refusedâ error
- ECONNRESET
-
âConnection resetâ error
- EDEADLK
-
âResource deadlock avoidedâ error
- EDEADLOCK
-
âFile locking deadlock errorâ error
- EDESTADDRREQ
-
âDestination address requiredâ error
- EDEVERR
-
âDevice error; e.g., printer paper outâ error
- EDOM
-
âMathematics argument out of domain of functionâ error
- EDOOFUS
-
âImproper function useâ error
- EDOTDOT
-
âRFS specific errorâ error
- EDQUOT
-
âDisk quota exceededâ error
- EEXIST
-
âFile existsâ error
- EFAULT
-
âBad addressâ error
- EFBIG
-
âFile too largeâ error
- EFTYPE
-
âInvalid file type or formatâ error
- EHOSTDOWN
-
âHost is downâ error
- EHOSTUNREACH
-
âHost is unreachableâ error
- EHWPOISON
-
âMemory page has hardware errorâ error
- EIDRM
-
âIdentifier removedâ error
- EILSEQ
-
âInvalid or incomplete multibyte or wide characterâ error
- EINPROGRESS
-
âOperation in progressâ error
- EINTR
-
âInterrupted function callâ error
- EINVAL
-
âInvalid argumentâ error
- EIO
-
âInput/output errorâ error
- EIPSEC
-
âIPsec processing failureâ error
- EISCONN
-
âSocket is connectedâ error
- EISDIR
-
âIs a directoryâ error
- EISNAM
-
âIs a named file typeâ error
- EKEYEXPIRED
-
âKey has expiredâ error
- EKEYREJECTED
-
âKey was rejected by serviceâ error
- EKEYREVOKED
-
âKey has been revokedâ error
- EL2HLT
-
âLevel 2 haltedâ error
- EL2NSYNC
-
âLevel 2 not synchronizedâ error
- EL3HLT
-
âLevel 3 haltedâ error
- EL3RST
-
âLevel 3 resetâ error
- ELAST
-
âLargest errno valueâ error
- ELIBACC
-
âCannot access a needed shared libraryâ error
- ELIBBAD
-
âAccessing a corrupted shared libraryâ error
- ELIBEXEC
-
âCannot exec a shared library directlyâ error
- ELIBMAX
-
âAttempting to link in too many shared librariesâ error
- ELIBSCN
-
â.lib section in a.out corruptedâ error
- ELNRNG
-
âLink number out of rangeâ error
- ELOOP
-
âToo many levels of symbolic linksâ error
- EMEDIUMTYPE
-
âWrong medium typeâ error
- EMFILE
-
âToo many open filesâ error
- EMLINK
-
âToo many linksâ error
- EMSGSIZE
-
âMessage too longâ error
- EMULTIHOP
-
âMultihop attemptedâ error
- ENAMETOOLONG
-
âFilename too longâ error
- ENAVAIL
-
âNo XENIX semaphores availableâ error
- ENEEDAUTH
-
âNeed authenticatorâ error
- ENETDOWN
-
âNetwork is downâ error
- ENETRESET
-
âConnection aborted by networkâ error
- ENETUNREACH
-
âNetwork unreachableâ error
- ENFILE
-
âToo many open files in systemâ error
- ENOANO
-
âNo anodeâ error
- ENOATTR
-
âAttribute not foundâ error
- ENOBUFS
-
âNo buffer space availableâ error
- ENOCSI
-
âNo CSI structure availableâ error
- ENODATA
-
âNo data availableâ error
- ENODEV
-
âNo such deviceâ error
- ENOENT
-
âNo such file or directoryâ error
- ENOEXEC
-
âExec format errorâ error
- ENOKEY
-
âRequired key not availableâ error
- ENOLCK
-
âNo locks availableâ error
- ENOLINK
-
âLink has been severedâ error
- ENOMEDIUM
-
âNo medium foundâ error
- ENOMEM
-
âNot enough space/cannot allocate memoryâ error
- ENOMSG
-
âNo message of the desired typeâ error
- ENONET
-
âMachine is not on the networkâ error
- ENOPKG
-
âPackage not installedâ error
- ENOPOLICY
-
âNo such policyâ error
- ENOPROTOOPT
-
âProtocol not availableâ error
- ENOSPC
-
âNo space left on deviceâ error
- ENOSR
-
âNo STREAM resourcesâ error
- ENOSTR
-
âNot a STREAMâ error
- ENOSYS
-
âFunctionality not implementedâ error
- ENOTBLK
-
âBlock device requiredâ error
- ENOTCAPABLE
-
âCapabilities insufficientâ error
- ENOTCONN
-
âThe socket is not connectedâ error
- ENOTDIR
-
âNot a directoryâ error
- ENOTEMPTY
-
âDirectory not emptyâ error
- ENOTNAM
-
âNot a XENIX named type fileâ error
- ENOTRECOVERABLE
-
âState not recoverableâ error
- ENOTSOCK
-
âNot a socketâ error
- ENOTSUP
-
âOperation not supportedâ error
- ENOTTY
-
âInappropriate I/O control operationâ error
- ENOTUNIQ
-
âName not unique on networkâ error
- ENXIO
-
âNo such device or addressâ error
- EOPNOTSUPP
-
âOperation not supported on socketâ error
- EOVERFLOW
-
âValue too large to be stored in data typeâ error
- EOWNERDEAD
-
âOwner diedâ error
- EPERM
-
âOperation not permittedâ error
- EPFNOSUPPORT
-
âProtocol family not supportedâ error
- EPIPE
-
âBroken pipeâ error
- EPROCLIM
-
âToo many processesâ error
- EPROCUNAVAIL
-
âBad procedure for programâ error
- EPROGMISMATCH
-
âProgram version wrongâ error
- EPROGUNAVAIL
-
âRPC program isnât availableâ error
- EPROTO
-
âProtocol errorâ error
- EPROTONOSUPPORT
-
âProtocol not supportedâ error
- EPROTOTYPE
-
âProtocol wrong type for socketâ error
- EPWROFF
-
âDevice power is offâ error
- EQFULL
-
âInterface output queue is fullâ error
- ERANGE
-
âResult too largeâ error
- EREMCHG
-
âRemote address changedâ error
- EREMOTE
-
âObject is remoteâ error
- EREMOTEIO
-
âRemote I/O errorâ error
- ERESTART
-
âInterrupted system call should be restartedâ error
- ERFKILL
-
âOperation not possible due to RF-killâ error
- EROFS
-
âRead-only file systemâ error
- ERPCMISMATCH
-
âRPC version wrongâ error
- ESHLIBVERS
-
âShared library version mismatchâ error
- ESHUTDOWN
-
âCannot send after transport endpoint shutdownâ error
- ESOCKTNOSUPPORT
-
âSocket type not supportedâ error
- ESPIPE
-
âIllegal seekâ error
- ESRCH
-
âNo such processâ error
- ESRMNT
-
âServer mount errorâ error
- ESTALE
-
âStale file handleâ error
- ESTRPIPE
-
âStreams pipe errorâ error
- ETIME
-
âTimer expiredâ error
- ETIMEDOUT
-
âConnection timed outâ error
- ETOOMANYREFS
-
cannot spliceâ error
- ETXTBSY
-
âText file busyâ error
- EUCLEAN
-
âStructure needs cleaningâ error
- EUNATCH
-
âProtocol driver not attachedâ error
- EUSERS
-
âToo many usersâ error
- EWOULDBLOCK
-
âOperation would blockâ error
- EXDEV
-
âInvalid cross-device linkâ error
- EXFULL
-
âExchange fullâ error
- NOERROR
-
No error