mardi 1 juin 2021

Catch exception in ruby

I have a function in ruby

def mark_completed
      var_a = self.a
      self.check_something
    end

The other function is

def check_something(query = nil)
   raise 'Some_exception' if condition_a_satisfy?
      return true
 end

See , the function check_something is raising exception , What I want is : - "To catch the exception and return false somehow" How can i do it?

Note : - I cannot change my check_something function.

Aucun commentaire:

Enregistrer un commentaire