Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Human Errors

Olivier Lacan
November 15, 2017

Human Errors

Runtime errors can sometimes turn into dark and unpleasant journeys which lead you to question the nature of reality. Thankfully, Ruby often provides friendly feedback for understanding the cause and remedy for exceptions. Yet, there are situations in which programmers don't receive clear enough context for what really caused an exception and how to address it. We'll look at Ruby's error feedback mechanisms and search for constructive ways in which they can be made more helpful to humans.

This talk was presented at RubyConf 2017.

Olivier Lacan

November 15, 2017
Tweet

More Decks by Olivier Lacan

Other Decks in Technology

Transcript

  1. error noun the state or condition of being wrong in

    conduct or judgment: the crash was caused by human error | the money had been paid in error. | ˈerər | a mistake: spelling errors | an error of judgment.
  2. Error (technical): a measure of the estimated difference between the

    observed or calculated value of a quantity and its true value.
  3. Origin: from Middle English errour, from Latin error (“wandering about”),

    infinitive of errō (“to wander, to err”). error noun | ˈerər |
  4. > explode ArgumentError: wrong number of arguments 
 (given 0,

    expected 1) from (irb):1:in `explode' from (irb):4 from /…/2.4.0/bin/irb:11:in `<main>'
  5. > explode ArgumentError: wrong number of arguments 
 (given 0,

    expected 1) from (irb):1:in `explode' from (irb):4 from /…/2.4.0/bin/irb:11:in `<main>'
  6. :

  7. > explode("abcd") ArgumentError: wrong number of arguments (given 1, expected

    0) from (irb):9:in `explode' from (irb):13 from /…/2.4.0/bin/irb:11:in `<main>'
  8. > explode("abcd") ArgumentError: wrong number of arguments (given 1, expected

    0; required keyword: code) from (irb):1:in `explode' from (irb):4 from /…/2.5.0-preview1/bin/irb:11:in `<main>'
  9. Joy

  10. “For me the purpose of life is partly to have

    joy. Programmers often feel joy when they can concentrate on the creative side of programming, 
 So Ruby is designed to make programmers happy.” Yukihiro “Matz” Matsumoto
  11. Elm

  12. irb(main):015:0> expode NameError: undefined local variable or method `expode' for

    main:Object Did you mean? explode from (irb):15 from /…/2.4.0/bin/irb:11:in `<main>'
  13. 10

  14. $ bin/rspec spec/ --bisect --seed 36929 Bisect started using options:

    "spec/ --seed 36929" Running suite to find failures... /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/shell_escape.rb:20:in `escape': undefined method `shellescape' for #<Pathname:/Users/olivierlacan/Development/cs/CodeSchool/lib> (NoMethodError) from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/runner.rb:154:in `block in load_path' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/runner.rb:154:in `map' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/runner.rb:154:in `load_path' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/runner.rb:26:in `command_for' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/runner.rb:68:in `block in run_locations' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/server.rb:27:in `capture_run_results' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/runner.rb:67:in `run_locations' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/runner.rb:50:in `original_results' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/example_minimizer.rb:114:in `block in prep' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/example_minimizer.rb:151:in `track_duration' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/example_minimizer.rb:113:in `prep' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/example_minimizer.rb:17:in `find_minimal_repro' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/coordinator.rb:37:in `block (2 levels) in bisect' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/server.rb:18:in `run' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/coordinator.rb:32:in `block in bisect' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/reporter.rb:191:in `close_after' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/coordinator.rb:31:in `bisect' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/bisect/coordinator.rb:19:in `bisect_with' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/invocations.rb:32:in `call' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:69:in `run' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:45:in `invoke' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/rspec-core-3.6.0/exe/rspec:4:in `<top (required)>' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:287:in `load' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:287:in `block in load' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:259:in `load_dependency' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-5.0.6/lib/active_support/dependencies.rb:287:in `load' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in `call' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/nakayoshi_fork-0.0.3/lib/nakayoshi_fork.rb:24:in `fork' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/nakayoshi_fork-0.0.3/lib/nakayoshi_fork.rb:24:in `fork' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/olivierlacan/.rbenv/versions/2.3.4/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from -e:1:in `<main>'
  15. 5

  16. ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write

    permissions for the /Library/Ruby/Gems/2.0.0 directory.
  17. 5

  18. “A library or application not having a functional need to

    rescue a possible error doesn't grant us license to ignore how confusing that error may be for the person who ultimately sees it.” Justin Searls
  19. * The built-in subclasses of Exception are: * * *

    NoMemoryError * * ScriptError * * LoadError * * NotImplementedError * * SyntaxError * * SecurityError * * SignalException * * Interrupt * * StandardError -- default for +rescue+ * * ArgumentError * * UncaughtThrowError * * EncodingError * * FiberError * * IOError * * EOFError * * IndexError