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
- http://aplawrence.com/Unixart/errors.html

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

···

--

Regards,
Arup Rakshit

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

···

Arup Rakshit <aruprakshit@rocketmail.com> 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 ?

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.

···

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

Arup Rakshit <aruprakshit@rocketmail.com> 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

--

Regards,
Arup Rakshit