Fix deprecation warning from using .to_err_msg()