fixed read length bugs when creating errors from mongo documents