  We obtain an expression for the error in the approximation of $f(A)
\boldsymbol{b}$ and $\boldsymbol{b}^T f(A) \boldsymbol{b}$ with rational Krylov
methods, where $A$ is a symmetric matrix, $\boldsymbol{b}$ is a vector and the
function $f$ admits an integral representation. The error expression is
obtained by linking the matrix function error with the error in the approximate
solution of shifted linear systems using the same rational Krylov subspace, and
it can be exploited to derive both a priori and a posteriori error bounds. The
error bounds are a generalization of the ones given in [T. Chen, A. Greenbaum,
C. Musco, C. Musco, SIAM J. Matrix Anal. Appl., 43 (2022), pp. 787--811]
(arXiv:2106.09806) for the Lanczos method for matrix functions. A technique
that we employ in the rational Krylov context can also be applied to refine the
bounds for the Lanczos case.
