adding better error handling to ruby