From: sto.mar@... Date: 2013-03-12T06:33:39+09:00 Subject: Re: Question regarding automating some Outlook/IMAP and pdf parsing functions w/ ruby? Am 10.03.2013 22:59, schrieb Joel Pearson: > unknown wrote in post #1100964: >> Am 10.03.2013 19:26, schrieb sto.mar@web.de: >>>> block. >>> >>> `rescue false' will rescue nearly all exceptions that might occur, which >>> is a potentially dangerous thing. Better use a begin/rescue/end block. >> >> I did not follow the start of the thread, but probably even better >> in this case would be to use `respond_to?' instead of relying on >> exceptions. > > These are valid points, specific error trapping is good, and avoiding > errors even better. Unfortunately I haven't been able to get > "respond_to?" working with ole methods, so it'll have to be rescue. > > Can't do a single line rescue with a specific class... > > if ( > begin > msg.Senderemailaddress =~ /@exampledomain.com$/i > rescue NoMethodError > false > end > ) && I would rather turn this around: begin sender = msg.Senderemailaddress rescue NoMethodError # whatever else if sender =~ ... ... end --