From: Leslie Viljoen Date: 2010-04-06T23:44:50+09:00 Subject: Custom Exceptions --00032555a9caac6cac0483927cd2 Content-Type: text/plain; charset=ISO-8859-1 Hi everyone I want to make a custom exception like so: class BillRowError < StandardError def initialize(field, index) @field = field @index = index end end I'll call this like so: raise(BillRowError.new(:roamingcalls, @index), "Roaming Calls field missing") if n.length == 0 But now I'd like to be able to modify the string that Ruby prints when the exception is not rescue'd. I thought I could add this method to the BillRowError class: def message @message + " field: #{@field}, row: #{@index}" end That almost works but I get a "instance variable @message not initialized" warning, which means Ruby is not setting @message in my object like I expected. Making my own message= method doesn't help. Can an exception object access and modify the message that gets passed in the "raise"? --00032555a9caac6cac0483927cd2--