Move error helpers into separate module