Replace `RuntimeError` with a more specific error.