How to read the descriptions of error codes from OS using Ruby?

I am looking for if there is any way to get the description out from the
system for the respective error codes .

[1] pry(main)> Errno.constants.take(5)
=> [:NOERROR, :EPERM, :ENOENT, :ESRCH, :EINTR]
[2] pry(main)> Errno.constants.take(5).map { |e|
Errno.const_get(e)::Errno }
=> [0, 1, 2, 3, 4]
[3] pry(main)>

Currently I am reading the description by using the error code, from
this link

Trying to get those out from the OS only. Is this possible ?

Arup R. [email protected] wrote:

I am looking for if there is any way to get the description out from the
system for the respective error codes .

Trying to get those out from the OS only. Is this possible ?

Something like the strerror(3) function in the C standard library?

In Ruby try doing something like: ex_class.new.message

Where ex_class is one of the constants under Errno::

So try:
Errno::EAGAIN.new.message

On Saturday, May 24, 2014 05:50:36 PM Eric W. wrote:

Where ex_class is one of the constants under Errno::

So try:
Errno::EAGAIN.new.message

Thanks for this. I was not aware of this. I thought, to fetch the
description
of such errors from OS related files, if any. Because that might be more
descriptive.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs