Mark Thomas already noted in
his comment that it looks like you are trying to handle errors yourself using some kind of string identifier. You can use exceptions instead:
class AddressError < StandardError; end class PermissionError < StandardError; end def something bla_permission_invalid
In the above code, something calls bla_permission_invalid , does its job, and returns true . If an exception occurs in bla_permission_invalid , it automatically extends to the call stack, you do not need to explicitly return it from something .
To handle the exception:
begin something rescue AddressError # handle address error rescue PermissionError # handle permission error end
Stefan
source share