Use err here and add some docs