Replace some uses of fail with raiseError