added onError fn to reader