diff --git a/lib/custom_errors.rb b/lib/custom_errors.rb index 53431de..ee092f6 100644 --- a/lib/custom_errors.rb +++ b/lib/custom_errors.rb @@ -7,7 +7,21 @@ 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