Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact

Background
You can check for some, but not all, errors. It's sometimes necessary (and often preferable even if not necessary) to write clean code that assumes correct operation, and provide rescue blocks telling Ruby what to do in the event of a failure.
Related technical and longer articles
errors v exceptions
Tips and short articles on this subject
Handling unusual and error conditions - exceptions
Ruby collections and strings - some new examples
Direct access to object variable (attributes) in Ruby
String to number conversion with error trapping in Ruby
What are exceptions - Python based answer
Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Ruby module R111
Exceptions.
Exercises, examples and other material relating to training module R111. This topic is presented on public courses Learning to program in Ruby, Ruby Programming

Ruby Programming - A Modern, Object Oriented, Portable Scripting language. This quickly moving course covers the fundamentals of the Ruby language for ...
http://www.wellho.net/course/rpfull.html  [course]
Learning to Program in Ruby - A Modern, Object Oriented, Portable Scripting language. Ruby is very much an object oriented language, and we concentrate ...
http://www.wellho.net/course/rlfull.html  [course]
It s said that between a half and 95% of a program will be given over to error checking. Indeed some of the web based programs on this site are little ...
http://www.wellho.net/solutions/general- ... tions.html  [longer article]
How do you check for run time errors in your program? You'll include tests with if statements in almost every program you write, to ensure that user ...
http://www.wellho.net/mouth/1875_Wha ... nswer.html  [short article]
From yesterday's Ruby course - a whole set of new examples on Ruby collections - arrays (which are ordered lists) and hashes (which are unordered). In ...
http://www.wellho.net/mouth/2621_Rub ... mples.html  [short article]
Rather than writing getters and setters, in many Object Oriented languages you can access the variables within an object directly. That can be dangerous ...
http://www.wellho.net/mouth/2620_Dir ... -Ruby.html  [short article]
"I can't answer that question in the way you expect" ... that's something that may be said to you occasionally - you ask someone what suit a playing card ...
http://www.wellho.net/mouth/2622_Han ... tions.html  [short article]

You can check for some, but not all, errors. It's sometimes necessary (and often preferable even if not necessary) to write clean code that assumes correct operation, and provide rescue blocks telling Ruby what to do in the event of a failure.

This topic is presented on public courses Learning to program in Ruby, Ruby Programming

Examples from our training material
bmi.rb   BMI (Body Mass Index) calculator
catcher   Converting String to Integer and handling errors
fsta.rb   File Reporter - assumes all is OK
fstb.rb   File Reporter - handle problems with open
fstc.rb   File Reporter - handle multiple problems and re prompt
mc   Catching user errors - a short demonstration
mighty.rb   Passing exceptions back to calling code
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from http://www.training-notes.co.uk.
Topics covered in this module
begin and end (and a mention of BEGIN and END).
Raise and rescue.
Throw and catch.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre. Also available is the Opentalk Forum for discussion of technical questions.


You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2010: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 344596 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho