# Defining own exceptions in rails

**URL:** <https://www.ruby-forum.com/t/defining-own-exceptions-in-rails/110638>\
**Category:** Rails\
**Created:** [July 28, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/defining-own-exceptions-in-rails/110638 "2007-07-28T17:41:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@andreim](https://www.ruby-forum.com/u/andreim)\
**Post date:** [July 28, 2007, 5:41pm UTC](https://www.ruby-forum.com/t/defining-own-exceptions-in-rails/110638/1 "2007-07-28T17:41:28Z")

</div>

Hi,

I would like to define my own exceptions in rails. I would like these  
definitions to be available throughout my application. What’s an  
elegant/good way to do this? The only way I can think of doing this is  
by putting all of my exception definitions in config/environment.rb,.  
Is there a better/standard way of doing this?  
Thanks!

–Andrei

---

<div class="post-metadata">

**Author:** ![andreim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c2a13f/32.png) [@andreim](https://www.ruby-forum.com/u/andreim)\
**Post date:** [July 28, 2007, 5:49pm UTC](https://www.ruby-forum.com/t/defining-own-exceptions-in-rails/110638/2 "2007-07-28T17:49:29Z")

</div>

andreim wrote:

> –Andrei

I’d say create an exceptions.rb in the lib/ directory of your rails  
application. The only “not nice” thing about that is that you still have  
to  
call require ‘exceptions’ from your environment.rb. You could do the  
same  
thing, without having to add configuration to environment.rb, by turning  
it  
into a plugin.

* * *

Ryan Carmelo Briones

–  
View this message in context:  
[http://www.nabble.com/defining-own-exceptions-in-rails-tf4162602.html#a11843935](http://www.nabble.com/defining-own-exceptions-in-rails-tf4162602.html#a11843935)  
Sent from the RubyOnRails Users mailing list archive at [Nabble.com](http://Nabble.com).
