Hi!
I've created a custom module (which currently only defines a new Exception class), and put it under lib/lib_th.rb
module LibTH
module Error
IDNotFound = Class.new
end
end
I should not need to require/include the module in my code, as it should be automatically loaded, since it follows the conventional naming rules.
But when i try and raise the IDNotFound
exception somewhere in my code:
res.size == 0 ? raise LibTH::Error::IDNotFound : res
I get the follwoing error:
SyntaxError (/Users/lrnz/code/ruby/corinna/app/models/treasure_hunt.rb:49: syntax error, unexpected tCONSTANT, expecting kDO or '{' or '('
res.size == 0 ? raise LibTH::Error::IDNotFound : res
^
/Users/lrnz/code/ruby/corinna/app/models/treasure_hunt.rb:49: syntax error, unexpected ':'
res.size == 0 ? raise LibTH::Error::IDNotFound : res
^):
app/controllers/treasure_hunts_controller.rb:50:in `show'
The strange thing is that I encounter no problems trying to raise the exception in script/console
:
>> raise LibTH::Error::IDNotFound
LibTH::Error::IDNotFound: LibTH::Error::IDNotFound
from (irb):70
Thanks!