Tool number should be written to Fanuc variable #4120 during tool change. For example, line T3 M6. Value 3 will be written into #4120 from it. Then the function getToolNameByNumber looks for tool name by tool number 3 in your Operation Navigator, and you may get the error like yours when the tool is not found there. The reason is wrong tool number either in the program or in the Operation Navigator.