Just in case, define safe_print right before the error handler.
It's still globally available to everyone.