Use getCode() as is done in line 797 (Fix #2820)