{"id":23,"date":"2003-05-28T10:47:52","date_gmt":"2003-05-28T09:47:52","guid":{"rendered":"http:\/\/www.nobugs.org\/blog\/archives\/2003\/05\/28\/another-win-for-exceptions\/"},"modified":"2003-05-28T10:47:52","modified_gmt":"2003-05-28T09:47:52","slug":"another-win-for-exceptions","status":"publish","type":"post","link":"https:\/\/www.nobugs.org\/blog\/archives\/2003\/05\/28\/another-win-for-exceptions\/","title":{"rendered":"Another win for exceptions"},"content":{"rendered":"<p>In C++, exceptions have many advantages over traditional &#8220;error return values&#8221;.  They&#8217;re harder to ignore, they&#8217;re a lot more flexible, you can use them in constructors, they don&#8217;t use up your return value slot, etc etc.  <\/p>\n<p>I&#8217;ve just noticed another advantage.  Imagine you&#8217;re doing old-style success\/failure return values.  Somewhere in a deep chain of calls there is a failure, which gets manually propogated up to the top level.  At the top-level, you get a failure value but how do you find the original failure point?  Usually by binary searching down through the code.  <\/p>\n<p>If you&#8217;re using exceptions, you can set the DevStudio debugger to stop at the point where an exception is thrown.  This immediately shows you the failure point.<\/p>\n<p>Then again, you could always just code in <a href=\"http:\/\/caml.inria.fr\">ocaml<\/a> and use it&#8217;s timetravelling debugger!  In ocaml, you run your program until you notice the failure, and then you go backwards in time to find the original failure point.  Ocaml rocks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In C++, exceptions have many advantages over traditional &#8220;error return values&#8221;. They&#8217;re harder to ignore, they&#8217;re a lot more flexible, you can use them in constructors, they don&#8217;t use up your return value slot, etc etc. I&#8217;ve just noticed another advantage. Imagine you&#8217;re doing old-style success\/failure return values. Somewhere in a deep chain of calls [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":0,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nobugs.org\/blog\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}