App vs Engine - raise error message

I have some code that I was duplicating across applications so I made it
an engine. The engine works fine but the only problem is when I raise an
error in the before_destroy method in my model (the model is not in the
engine).

Based on the example code below; if I have this code in a controller
that is not in a engine I will get the following error:

“Fee type is in use”

Which is exactly what I want. However, if I have that exact same code
in my engine I get the full path to the file that raised the error plus
the error message “Fee type is in use”.

“/Users/weshays/temp/myapp/config/…/app/models/fee_type.rb:6:in
`before_destroy’: Fee type is in use”

I cannot figure out how to only get the error message without the other
stuff (path and method) as this could be a possible security risk.

I have tried the different options for the raise method but with no
luck.

I am using Ruby 1.8.5 and Rails version 1.2.3.
The following sample code is what’s in question.

*** Model ***

has_many :ga_locations

def before_destroy
raise ‘Fee type is in use’ if self.ga_locations.count > 0
end

*** Controller ***

begin
item.destroy
rescue Exception => err
flash[:error] = err.message
end


Any help on this would be appreciated.

-Wes


James “Wes” Hays
Great Basin Development
P.O.Box 3503, Reno, Nevada 89505
http://www.gbdev.com