As for me, the best way to get error name by int value is that. And it's works fine for me ;)
<?php
array_flip(array_slice(get_defined_constants(true)['Core'], 1, 15, true))[$type];
//the same in readable form
array_flip(
array_slice(
get_defined_constants(true)['Core'],
1,
15,
true
)
)[$type]
?>