code: def __safe_handler_callback(self, handler, method_name, *args, **kwargs):
          # type: (Any, str, *Any, **Any) -> Any
          
          if handler is None or method_name is None:
              return None
  
          # Behavior flags
          only_boolean = kwargs.pop("only_boolean", False)
          none_as_true = kwargs.pop("none_as_true", False)
  
          # Get the method for each handler
          try:
              method = getattr(handler, method_name)
          except AttributeError:
              # Method not found
              result = None
          else:
              try:
                  # Call it
                  result = method(*args, **kwargs)
              except Exception as ex:
                  # No result
                  result = None
  
                  # Log error
                  self._logger.exception(
                      "Error calling handler '%s': %s", handler, ex
                  )
  
          if result is None and none_as_true:
              # Consider None (nothing returned) as True
              result = True
  
          if only_boolean:
              # Convert to a boolean result
              return bool(result)
  
          return result
docs: Calls the given method with the given arguments in the given handler.
          Logs exceptions, but doesn't propagate them.
  
          Special arguments can be given in kwargs:
  
          * 'none_as_true': If set to True and the method returned None or
                            doesn't exist, the result is considered as True.
                            If set to False, None result is kept as is.
                            Default is False.
          * 'only_boolean': If True, the result can only be True or False, else
                            the result is the value returned by the method.
                            Default is False.
  
          :param handler: The handler to call
          :param method_name: The name of the method to call
          :param args: List of arguments for the method to call
          :param kwargs: Dictionary of arguments for the method to call and to
                         control the call
          :return: The method result, or None on error