Skip to content

bitmakerlabs/exceptions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Exceptions

This mini-project demonstrates the use of exceptions in the context of the Hangman game.

To run it, simply run from command line:

ruby hangman_runner.rb

Further Reading & References

The Exception class

http://www.ruby-doc.org/core-1.9.3/Exception.html

The StandardError class

Inherits from Exception class. We should technically be inheriting from this in our demo code!! http://www.ruby-doc.org/core-1.9.3/StandardError.html

Unit Testing

You can use assert_raise and assert_nothing_raised to test methods that can throw exceptions.
http://ruby-doc.org/stdlib-1.9.3/libdoc/test/unit/rdoc/Test/Unit/Assertions.html#method-i-assert_nothing_raised
http://ruby-doc.org/stdlib-1.9.3/libdoc/test/unit/rdoc/Test/Unit/Assertions.html#method-i-assert_raise

Advanced (somewhat)

You can use else and ensure and multiple rescue statements ... oh my!
See this answer on SO

About

Understanding exceptions and exception handling

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages