Replace a call to BUG by an error return.