From: John Carter Date: 2005-11-14T04:40:35+09:00 Subject: Re: Logging vs. Exceptions On Fri, 11 Nov 2005, lroland@gmail.com wrote: > begin > session = UNIXSocket.new(@socket) > session.send(msg,0) > data = session.recvfrom(512)[0] # [0] ensures we only get clam's > respons > session.close() > rescue > raise ScannerException.new("unable to use socket: #{@socket}") > end Evil! Evil! Evil! DON'T _DO_ THAT! You have now masked every error in that section and munged them into one. You could have a simple programming bug, or something weird may be happening on your system, but it will all collapse into one error and you will have not the foggiest idea what happened or why. So try one of these variants... best practice would be trap just those exceptions you know can arise.. rescue ASpecificError raise ScannerExecption.new(.....) end or (if you must catch all) at least record what it was, don't mask the unexpected. rescue Exception => details raise ScannerException.new( "blah blah #{details}") end or, since you are not really adding much of value at this level, just don't catch anything at this level, (never catch an exception you don't know how to handle.) John Carter Phone : (64)(3) 358 6639 Tait Electronics Fax : (64)(3) 359 4632 PO Box 1645 Christchurch Email : john.carter@tait.co.nz New Zealand Carter's Clarification of Murphy's Law. "Things only ever go right so that they may go more spectacularly wrong later." From this principle, all of life and physics may be deduced.