Uvm report catcher functionality

Hi,
we have a requirement to limit the number of failure or success messages of an assertion to certain threshold. (if the assertion failure/success messages are more than a threshold, they will not be displayed). We are trying to achieve this using uvm_report_catcher class.
But we are not clear how catch method needs to be modified for this requirement. Can someone help here please.
regards,
-sunil

Should be something along the lines of:

class message_filter extends uvm_report_catcher;
  local int unsigned num_occurrences;

  function action_e catch();
    if (is_relevant_message()) begin
      num_occurrences++;
      if (num_occurrences >= MAX_NUM_OCCURRENCES)
        return CAUGHT;
    end
    return THROW;
  endfunction
endclass