From f42c52a1bb3d36929cbda596cdefef7bc086254e Mon Sep 17 00:00:00 2001 From: 415CA Date: Mon, 29 Jun 2020 15:40:27 -0400 Subject: [PATCH] Done. --- README.md | 1 - lib/custom_errors.rb | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1dcb4d3..2f32802 100644 --- a/README.md +++ b/README.md @@ -277,7 +277,6 @@ an instance of the `PartnerError` class and `puts` out the result of calling At this point, the code in `custom_errors.rb` should look like this: -```ruby class Person attr_accessor :partner, :name diff --git a/lib/custom_errors.rb b/lib/custom_errors.rb index 53431de..3fd32fe 100644 --- a/lib/custom_errors.rb +++ b/lib/custom_errors.rb @@ -7,15 +7,24 @@ def initialize(name) def get_married(person) self.partner = person - person.partner = self + if person.class != Person + begin + raise PartnerError + rescue PartnerError => error + puts error.message + end + else + person.partner = self + end end + class PartnerError < StandardError + def message + "you must give the get_married method an argument of an instance of the person class!" + end + end end beyonce = Person.new("Beyonce") beyonce.get_married("Jay-Z") puts beyonce.name - - - -