tag:blogger.com,1999:blog-2911377234335400421.post3718759120432896339..comments2023-12-26T12:52:50.667-06:00Comments on Rails on Edge: Begin Rescue Else Endrledge21http://www.blogger.com/profile/07280624261775331061noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-2911377234335400421.post-27700801654281731262012-04-04T03:47:32.954-05:002012-04-04T03:47:32.954-05:00What namely you are writing is a horrible mistake....What namely you are writing is a horrible mistake.niroahttp://niroa.orgnoreply@blogger.comtag:blogger.com,1999:blog-2911377234335400421.post-52834600642852705512011-06-18T03:45:44.198-05:002011-06-18T03:45:44.198-05:00@soro please have a look on this example scenario:...@soro please have a look on this example scenario: <br /> Your application gives information about departments in your company. You are asked by your boss to give a telephone number to HR department. You check in application but unfortunately your database has problems, let say some locks on department table make it unreadable or connection pool number exceeded (many things can go wrong). What do you see? You see "No Department" and you have no idea that HR department exists but your application are having exceptions. With such wonderful information "No HR department in our company" you get back to your boss. What do you think will happen next? Is your application reliable? Are your application users reliable? (in this case user is you).<br /><br /> You should always rescue only exceptions that you are expecting (TimeoutException etc)<br /><br /> I hope you get a point.<br /><br />BR, meceomeceohttps://www.blogger.com/profile/04705053050784243886noreply@blogger.comtag:blogger.com,1999:blog-2911377234335400421.post-5966904823884554282010-07-14T09:54:41.609-05:002010-07-14T09:54:41.609-05:00Thank you! Helped me get some safety into my appli...Thank you! Helped me get some safety into my application. I am catching all those bad people trying to grab orders they shouldn't be seeing.<br /><br />Have a nice life!<br /><br />MichaelAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2911377234335400421.post-77720987718730269172010-01-04T16:36:18.640-06:002010-01-04T16:36:18.640-06:00@Soro
The point is that dependent on the error you...@Soro<br />The point is that dependent on the error you might want to do more than only print "No Department" to the user.<br />Maybe you additionally want to fire a systems management event if (and only if) you have a db error.<br /><br />Greetings<br />HeinzAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2911377234335400421.post-32574442659596942602009-12-09T06:28:30.455-06:002009-12-09T06:28:30.455-06:00rescue ROX! And the inline use is more 'polite...rescue ROX! And the inline use is more 'polite' I must say.<br /><br />@meceo argument is silly "I don't like rescue in this example, that will catch all exceptions, no matters what went wrong"<br />Isn't that the whole point?!<br /><br /><b>What</b> if someone just destroyed the dept. he was looking for?Anonymoushttps://www.blogger.com/profile/03884089851791731618noreply@blogger.comtag:blogger.com,1999:blog-2911377234335400421.post-19048592102470261942009-07-27T03:20:34.754-05:002009-07-27T03:20:34.754-05:00I don't like rescue in this example, that will...I don't like rescue in this example, that will catch all exceptions, no matters what went wrong<br /><br />dep = Department.find_by_id(thisdept)<br />dep.present? ? dep.name : "No Department"<br /><br />no rescue requiredmeceohttps://www.blogger.com/profile/04705053050784243886noreply@blogger.comtag:blogger.com,1999:blog-2911377234335400421.post-54912730233033157912008-09-22T23:53:00.000-05:002008-09-22T23:53:00.000-05:00thats more like itthats more like itAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-2911377234335400421.post-39708885672628760542008-04-14T12:24:00.000-05:002008-04-14T12:24:00.000-05:00Awesome, didn't know about inline rescues, thanks ...Awesome, didn't know about inline rescues, thanks for the tip.rledge21https://www.blogger.com/profile/07280624261775331061noreply@blogger.comtag:blogger.com,1999:blog-2911377234335400421.post-9953003768608285972008-04-14T11:31:00.000-05:002008-04-14T11:31:00.000-05:00Hey man --How about this?def deptname Department....Hey man --<BR/><BR/>How about this?<BR/><BR/>def deptname<BR/> Department.find(thisdept).name rescue "No Department"<BR/>end<BR/><BR/>Inline rescues are my friend ;-)Derek Bernerhttps://www.blogger.com/profile/15831188663707535117noreply@blogger.com