How to stop counting errors when uvm_severity is changed?

I’m changing the uvm_severity of an specific message id from UVM_ERROR to UVM_INFO but at the end of the simulation the tests still fails because the severity is being changed but the error count is still being incremented.

What do I need to do to stop counting errors of messages that have their severity changed?

This is the code I’ve implemented:



class top_report_catcher extends uvm_report_catcher;

  uvm_severity id_severity[string];
  uvm_action   id_action[string];

  `uvm_object_utils(top_report_catcher)

  function new(string name="top_report_catcher");
  endfunction

  virtual function void add_change(uvm_severity severity="UVM_INFO", string message_id);
    id_severity[message_id] = severity;
    id_action[message_id] = UVM_NO_ACTION;
  endfunction

  virtual function action_e catch();
    string message_id = get_id();
    if (id_severity.exists(message_id)) begin
        set_severity(id_severity[message_id]);
        set_action(id_action[message_id]);
      end
    end
    return THROW;
  endfunction
endclass


In reply to mvetromille:

You are not showing enough code to know what might be wrong. The following complete example works for me.

`include "uvm_macros.svh"
import uvm_pkg::*;
class Demoter extends uvm_report_catcher;
  function new(string name="test1_demoter");
    super.new(name);
  endfunction : new
  function action_e catch();
    if(get_severity() == UVM_ERROR)
      set_severity(UVM_WARNING);
    return THROW;
  endfunction : catch
endclass : Demoter

class myTest extends uvm_test;
  `uvm_component_utils(myTest)
  Demoter demoter;
  function new(string name = "my_test",uvm_component parent=null);
    super.new(name,parent);
  endfunction : new
  virtual function void build_phase(uvm_phase phase);
    demoter = new("demoter");
  endfunction : build_phase
  
  task run_phase(uvm_phase phase);
    uvm_report_cb::add(null, demoter);
    `uvm_error(get_type_name(),"Catch me if you can")
  endtask : run_phase
endclass : myTest

module top();
  initial run_test("myTest");
endmodule