fix(tls): only setup the error callback if non-nil