What do you think?


Exceptional Ruby: Master the Art of Handling Failure in Ruby
Writing code that works is hard. Writing code that handles unexpected errors and still works is really hard. Most of us learn by trial and error. This short book removes the uncertainty. With over 100 pages of content and dozens of working examples, you’ll learn everything from the mechanics of how exceptions work to how to design a robust failure management architecture for your app or library. Whether you are a Ruby novice or a seasoned veteran, Exceptional Ruby will help you write cleaner, more resilient Ruby code.
102 pages, ebook
First published May 1, 2011
Ratings & Reviews
Friends & Following
Create a free account to discover what your friends think of this book!
Community Reviews
Displaying 1 - 17 of 17 reviews
November 22, 2012
Great book!
Here are my quizz notes:
- What is the diff bt raise and fail?
=> no diff
- Are raise//fail ruby keywords or methods?
=> Kernel#raise (are methods)
- Re-raise last exception
=>
# With no arguments will re-raise exception in $! If nil then RuntimeError
# note $! value is nil initialized as soon as the begin..rescue.end block terminates
raise
- What is the third argument of raise and give an example of what to put there.
=> the backtrace, use for example Kernel#caller
- What is catch/throw used for?
=> not related to exceptions, catch/throw allows you
to quickly exit blocks back to a point where a catch is defined for a specific symbol
- Diffs bt `redo` vs `retry`
=> Both ruby keywords are used to re-execute parts of a loop but:
redo only repeats the current iteration
retry repeats the whole loop from the start in 1.8 but in 1.9 gives SyntaxError: Invalid retry
Note retry should only be used inside immediate rescue blocks
- What can you use to ignore/continue/retry//etc on every ruby program error, console based?
=> the `hammertime` gem. just require 'hammertime'
- Test unit, describe the test helpers (assertions) for
equality, check nothing raised, check something raised.
=>
assert_equal val1, val2
assert_nothing_raised { block }
# ensure some exception is not raised
assert_nothing_raised ArgumentError { block }
# ensure something is raised
assert_raise { block }
# ensure some exception is raised
assert_raise NameError { puts asd }
Here are my quizz notes:
- What is the diff bt raise and fail?
=> no diff
- Are raise//fail ruby keywords or methods?
=> Kernel#raise (are methods)
- Re-raise last exception
=>
# With no arguments will re-raise exception in $! If nil then RuntimeError
# note $! value is nil initialized as soon as the begin..rescue.end block terminates
raise
- What is the third argument of raise and give an example of what to put there.
=> the backtrace, use for example Kernel#caller
- What is catch/throw used for?
=> not related to exceptions, catch/throw allows you
to quickly exit blocks back to a point where a catch is defined for a specific symbol
- Diffs bt `redo` vs `retry`
=> Both ruby keywords are used to re-execute parts of a loop but:
redo only repeats the current iteration
retry repeats the whole loop from the start in 1.8 but in 1.9 gives SyntaxError: Invalid retry
Note retry should only be used inside immediate rescue blocks
- What can you use to ignore/continue/retry//etc on every ruby program error, console based?
=> the `hammertime` gem. just require 'hammertime'
- Test unit, describe the test helpers (assertions) for
equality, check nothing raised, check something raised.
=>
assert_equal val1, val2
assert_nothing_raised { block }
# ensure some exception is not raised
assert_nothing_raised ArgumentError { block }
# ensure something is raised
assert_raise { block }
# ensure some exception is raised
assert_raise NameError { puts asd }
December 20, 2020
This book is a deep dive into Ruby exceptions. It starts with the explanation of Ruby exceptions and exception handling mechanisms and goes on suggesting some techniques to deal with them effectively. There is very little overlap with Confident Ruby. Even though this book covers a small part of the language, it is full of practical insights. I would recommend this to anyone looking to improve their Ruby skills.
November 28, 2016
I learnt several Ruby specific things from the book:
- fail is just alias for raise
- use raise as default value when key is expected
- it is possible to include module in error and then rescue by module.
There were some general things, but they better covered in referenced books.
- fail is just alias for raise
- use raise as default value when key is expected
- it is possible to include module in error and then rescue by module.
There were some general things, but they better covered in referenced books.
May 5, 2017
It's a good book. It is easy to read and Avdi explain ruby exceptions in depth. I've learned a lot about it and there are many things I didn't know exists.
I've missed an good index for the pratices shown in the book, like a resume of the patterns presented with code samples.
I've missed an good index for the pratices shown in the book, like a resume of the patterns presented with code samples.
August 19, 2017
A few bright moments, some neat tricks; good enough for a lengthy blog post. I've expected either a bit more depth or better tips for error handling beyond common sense, maybe even both.
January 22, 2018
Great book, great insights, it was a good weekend read!
July 6, 2011
If you are a long term Rubyist, you probably know Avdi Grim and his writings. This little book covers a topic that lots of programming books just gloss over or skip altogether, exceptions. It's a thorough wrap-up of everything Rubyists should know about exceptions and even mentioned a couple of things that got me thinking about the way I deal with exceptions in Ruby, and that's after 8 or 9 years of using the language. Definitely recommended!
May 20, 2015
Worth reading and interesting stuff in here. I had been expecting more of what was in the last section, which is higher-level exception handling strategy, vs a lot of detail into all the weird things you could do to mess with how Ruby exception throwing works--interesting to learn, but not as directly useful imo.
January 16, 2016
Rather than a deep dive under the hood of Ruby's exceptions, I was hoping for more of a surface-level, practical guide to how and when to use exceptions in Ruby - especially in Rails apps. It does cover that side a bit, but only at the end. For me, most of the content in the book was interesting but esoteric stuff that I'll likely forget, and never need to apply in real live.
December 11, 2012
After reading this book, it became apparent to me how under-appreciated the discussion of exception and error handling is in the programming literature. This book is definitely worth reading.. and rereading. It is short and to the point, describes practical techniques which can be simply applied.
March 28, 2014
I recommend reading this book. It shows plenty of techniques how to handle deal with failures and errors. My favorite was when it showed how to 'tag' an exception like IOException to be able to caught as OurLibrary:OurException. :) + Many More...
September 22, 2011
This book is a quick read that any Ruby Developer would be well served to read.
April 16, 2012
Fun to read. Shows you how to think of a more rubyish way of handeling errors.
April 18, 2012
A nice, succinct read on exception handling in Ruby. I learned some good stuff here, especially guidance on when exceptions should be used.
Read
July 16, 2012Well worth the read. Short, but packed.
December 26, 2012
Fast paced, easy to follow and very good recommendations about handling failures with the ruby language
November 29, 2014
This book brings a whole new meaning to handling exceptions. There are many things you will learn from this book, even if you are a seasoned Ruby developer.
Displaying 1 - 17 of 17 reviews











