John Bachir John Bachir - 6 months ago 19
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

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

Comments