Avoid ugly exception in log on unknown inv type
It is unexpected behavior for ToString to raise an exception. It
is expected to do a best-effort attempt at formatting but never fail.
Catch the exception and simply print unknown inv types as hexadecimal.
Fixes #9110.