John Bachir John Bachir - 2 years ago 80
Ruby Question

What is a conventional place to keep custom Exception definitions in a rails project?

When making one's own custom exceptions like

class ThingExploded < StandardError; end
class ThingIsMissing < StandardError; end

Where is a good place to keep these? I was considering lib/exceptions.rb… and also pondering if it would be more appropriate to somehow put them closer to the code that uses them.

Answer Source

I'm going with app/models/model_name/exceptions.rb, keeping them inside the module.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download