iteration

Exceptional Failure

Episode Summary

This week we talk about what is a failure, and the life-cycle of an exception.

Episode Notes

Exceptional Failure

In this short season, we are going through EXceptional Ruby by Advi Grimm

What is a failure?

Let's talk about some definitions first:

  1. Exception - the occurrence of an abnormal condition during the execution of a software element.
  2. Failure - the inability of a software element to satisfy its purpose
  3. Error - the presence in the software of some element not satisfying its specification

"Failures cause exceptions which are due to errors"

The life-cycle of an exception


🗣 Discussion: When do you find yourself using raise?

🗣 Discussion: When do you find yourself using rescue?

syntax

Moar Code

begin
  raise RuntimeError, 'specific error'
rescue StandardError => error
  puts "Generic error handler: #{error.inspect}"
rescue RuntimeError => error
  puts "runtime error handler: #{error.inspect}"
end

🗣 Discussion: Have you ever used retry?

tries = 0

begin
  tries += 1
  puts "trying #{tries}"
  raise
rescue
  retry if tries < 3
  puts 'I give up'
end

Picks:

JP: Overcast https://overcast.fm/

John: Apple Refurbished