How to convert $error to `uvm_error?

I have a checker that is used in directed system Verilog testbench as well as in UVM testbench. Errors are reported as $error(). But, I’m not finding a way to stop the test after a certain number of errors using plus args. I can’t use uvm_error and UVM_MAX_QUIT_COUNT instead of $error since uvm_error is not supported in system Verilog testbench. So, I want to convert $error to uvm_error at least in the uvm testbench by using define in the checker. Is there any way to write a wrapper to use uvm_error instead of $error?

In reply to ravitejavoora:

First of all, there no reason you can’t use `uvm_error in a SystemVerilog directed non-uvm testbench. You can make full use of UVM’s reporting mechanism even outside a class based testbench. Most tools make it simple to include the uvm_macros.svh and import the uvm_pkg without have to compile it yourself.

You could even define your own `uvm_error macro so there’s no need to include or import.

`define uvm_error(ID,MSG) uvm_pkg::uvm_report_error(ID,MSG);