libcore: Make fail handlers optional

Some users, particularly those targeting embedded systems, would rather avoid depending on `fmt` due to its effect on code size. See #17886.