Download Exceptional Ruby by Avdi Grimm PDF

By Avdi Grimm

Unheard of Ruby is an in-depth advisor to exceptions and failure dealing with in Ruby. Over a hundred pages of content material and dozens of operating examples hide every thing from the mechanics of the way exceptions paintings to tips on how to layout a strong failure administration structure in your app or library. even if you're a Ruby amateur or a professional veteran, unparalleled Ruby can help you write cleanser, extra resilient Ruby code.

What you are going to Find:

a close examine the lifecycle of a Ruby exception.
Overriding Kernel#raise for enjoyable and profit.
possible choices to exceptions, for whilst "fail quickly" is not the correct answer.
how you can write a crash logger.
complicated dynamic exception matching in rescue clauses.
heading off failure cascades with the Barricade and Circuit Breaker patterns.
five inquiries to ask ahead of elevating an exception.
Exception defense checking out for serious methods.
tips on how to create an mistakes API in your library that might make different builders are looking to kiss you.
the three exception sessions each app or library needs.
and lots more and plenty, a lot more... over a hundred pages of tips, guidance, and outstanding hacks!

Show description

Read or Download Exceptional Ruby PDF

Best software development books

Design Patterns: Elements of Reusable Object-Oriented Software

4 top-notch authors current the 1st ebook containing a catalog of object-oriented layout styles. Readers will the way to use layout styles within the object-oriented improvement strategy, easy methods to clear up particular layout difficulties utilizing styles, and achieve a standard vocabulary for object-oriented layout.

Extreme Programming Perspectives

Offers forty seven articles that characterize the insights and useful knowledge of the leaders of the XP neighborhood. provide experience-based recommendations for imposing XP successfully and offers winning transitioning innovations. Softcover.

Decision Making with Dominance Constraints in Two-Stage Stochastic Integer Programming

Two-stage stochastic programming types are regarded as appealing instruments for making optimum judgements lower than uncertainty. often, optimality is formalized by means of utilizing statistical parameters corresponding to the expectancy or the conditional price in danger to the distributions of target values. Uwe Gotzes analyzes an method of account for possibility aversion in two-stage versions dependent upon partial orders at the set of genuine random variables.

Additional resources for Exceptional Ruby

Example text

NestedException 36 Prepared exclusively for Joshua Levitt 36 THE LIFE-CYCLE OF AN EXCEPTION one. Ruby’s built-in Exceptions don’t support nesting, but adding nesting to your own exception classes is trivial. inspect}" end Listing 17: A nested exception implementation. ) (see line 3). This enables the object to “magically” discover the originating exception on initialization. If there is no currently active exception the original attribute will be set to nil. new("Error B", error) John D. Hume has created a gem “Nestegg”6 which implements nested exceptions with some nice backtrace formatting.

In this situation, failing early clearly isn’t the most useful approach. What you really need is a way to proceed through the steps of the provisioning process and then get a report at the end telling you what parts succeeded and what parts failed. There are several approaches to to implementing this kind of deferred/optional failure handling; but all of them are variations on the theme of sideband data. FailFast 56 Prepared exclusively for Joshua Levitt ALTERNATIVES TO EXCEPTIONS 57 Sideband data Every method has a primary channel of communication back to its caller: its return value.

As usual, Ruby has the flexibility to oblige us. The following code redefines raise to prevent a secondary exception from being raised until the active exception has been handled: module NoDoubleRaise def error_handled! $! = nil end 5 10 def raise(*args) if $! = $! first}, aborting" exit! false else super end end end 15 class Object include NoDoubleRaise end Listing 21: Disallowing double-raise. With this code in place, a secondary failure will cause the program to end. ) in order to raise a new exception.

Download PDF sample

Rated 4.41 of 5 – based on 24 votes