How can i find out the type of variable

hello,
I would like to know if it is possible to know the type of variable?
I wrote the following parametrize function and want to know what is the variable type in case of failure:

class paramerized_functions_class #(type enum_type = event_type_e);
    
// this function casts string to enumerated variable 
static function enum_type string2enum_cast (string str);
    
    enum_type e = e.first();
    // go trough the enums and check if str is equal to the enum name 
    do begin
        if (e.name() == str)
            return e;
        e=e.next();
    end while (e != e.last()); // stop when the last enumerated value is reached
    
    //if reached here, no match was found and casting failed
    `**uvm_fatal("CAST", $sformatf("string to enum casting failed, %s is not of type %S", str, ??? ));**
    
endfunction : string2enum_cast 
    
endclass : paramerized_functions_class

thanks, Kobi.

In reply to kobiyonai:

$typename

In reply to dave_59:

thanks Dave,
I see that this function returns the enum definition but not the typedef name.

reporter string to enum casting failed, couldn’t cast SYNCC string to enum{RX_FRAME_IN=32’sd0,RX_FRAME_OUT=32’sd1,TX_FRAME_IN=32’sd2,TX_FRAME_OUT=32’sd3,RX_PFC_IN=32’sd4,TX_PFC_OUT=32’sd5,SYNC=32’sd6,CONF=32’sd7}