# Adding to the Errno module

**URL:** <https://www.ruby-forum.com/t/adding-to-the-errno-module/191857>\
**Category:** Ruby\
**Created:** [July 19, 2010, 10:03pm UTC](https://www.ruby-forum.com/t/adding-to-the-errno-module/191857 "2010-07-19T22:03:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjgp2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@mjgp2](https://www.ruby-forum.com/u/mjgp2)\
**Post date:** [July 19, 2010, 10:03pm UTC](https://www.ruby-forum.com/t/adding-to-the-errno-module/191857/1 "2010-07-19T22:03:01Z")

</div>

[accidentally posted this from an non-subscribed address a few minutes  
ago … hopefully it doesn’t show up twice]

I’m trying to add some missing handlers to the Errno module on my  
system. But, clearly I’m missing something here, as I’m getting an  
error I don’t understand when I try a raise using any of them.

My test code:

irb(main):001:0\> module Errno  
irb(main):002:1\> class EFTYPE \< SystemCallError; end  
irb(main):003:1\> end  
=\> nil  
irb(main):004:0\> raise Errno::EFTYPE, “trying to raise an error here”,  
caller  
TypeError: can’t convert Module into Integer  
from (irb):4:in `initialize' from (irb):4:in`exception’  
from (irb):4:in `raise' from (irb):4 from /opt/local/bin/irb:12:in`’  
irb(main):005:0\>

I’m using things like the webrick standard library as an example here,  
but clearly I’ve got something wrong. Anyone have any suggestions?

Matt

---

<div class="post-metadata">

**Author:** ![mjgp2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@mjgp2](https://www.ruby-forum.com/u/mjgp2)\
**Post date:** [July 20, 2010, 5:33pm UTC](https://www.ruby-forum.com/t/adding-to-the-errno-module/191857/2 "2010-07-20T17:33:58Z")

</div>

Hi Matt.

I think you need to define Errno::EFTYPE::Errno and assign it an  
integer.

module Errno  
class EFTYPE \< SystemCallError  
Errno = 42  
end  
end

Now in IRB, you’ll get something like the following:

irb(main):014:0\> raise Errno::EFTYPE, “trying to raise an error here”  
Errno::EILSEQ: Illegal byte sequence - trying to raise an error here  
from (irb):14

Notice that 42 is the “integer operating system error number  
corresponding  
to” [1](http://ruby-doc.org/docs/ProgrammingRuby/html/ref_m_errno.html) Errno::EILSEQ. You may want to select a different (the  
appropriate?) value.

HTH,  
Yaser
