D
dkmd_nielsen
My application has a common routine to format error messages:
def FLIO.display_error(clss,err)
ln = '-'*70
lbl = "#{clss}_#{sprintf('%04i',err[:num])}"
ln[(ln.length - lbl.length)/2,lbl.length] = (' Error: ' + lbl +
' ')
puts ln,err[:msg],ln
end
....
FLIO.display_error(self.class,
{:num => 5,
:msg => "Test error message"})
raise ArgumentError
Questions:
Should I call the routine to format the message and return to the
caller and raise the exception, as implemented above? For IDE
purposes, this would set the trace to the right area. Or should I
pass the exception to the routine and raise it there? This would be
one less line of code for every exception trap.
What are your recommendations, in general, or raising exceptions in an
application?
Thank you
dvn
def FLIO.display_error(clss,err)
ln = '-'*70
lbl = "#{clss}_#{sprintf('%04i',err[:num])}"
ln[(ln.length - lbl.length)/2,lbl.length] = (' Error: ' + lbl +
' ')
puts ln,err[:msg],ln
end
....
FLIO.display_error(self.class,
{:num => 5,
:msg => "Test error message"})
raise ArgumentError
Questions:
Should I call the routine to format the message and return to the
caller and raise the exception, as implemented above? For IDE
purposes, this would set the trace to the right area. Or should I
pass the exception to the routine and raise it there? This would be
one less line of code for every exception trap.
What are your recommendations, in general, or raising exceptions in an
application?
Thank you
dvn