Unitialized constant when using custom exceptions

Viewed 3031

I'm trying to create a custom exceptions for my app. I have a sample library in my libs folder with the following folder structure:

- lib/
|
|--social/
  |
  |-- bandcamp.rb

And this bandcamp.rb file contents looks following:

module Social
  class ExampleException < Exception; end

  class Bandcamp
    def some_method()
    end
  end
end

And the thing is, i can use a Social::Bandcamp.new.some_method anywhere in my app and it works just fine but i can't access Social::ExampleException nor raise it anywhere. It gives me

NameError: uninitialized constant Social::ExampleException

Have you any idea what am i possibly doing wrong? I'm quite new to creating own libs so i'm sure i've misunderstood something.

2 Answers
Related