title: Detect when image not found using Compose Coil
body: <p>I am populating my images using coil in jetpack compose and the issue I face is that I am not able to programmatically identify if the url is no longer valid.</p>
  <pre><code>val imageUrl = &quot;www.someinvalidurl.com&quot;
  val painter = rememberImagePainter(
      data = imageUrl
  )
  
  Image(
      painter = painter
  )
  </code></pre>
  <p>The url was previously valid but is not valid anymore. Coil shows the default placeholder url but then I want to identify this failure and attempt to get an image from a different url. I have tried this,</p>
  <pre><code>if (painter.state is ImagePainter.State.Error) {
      //failed so try to get an image from a different url
  }
  </code></pre>
  <p>But the problem with this is that this block is called even for valid urls.</p>
  <p>I am using the following version of coil :</p>
  <pre><code>implementation(&quot;io.coil-kt:coil-compose:1.4.0&quot;)
  </code></pre>
  <p>Is there a different right way of identifying invalid URLs in coil while using jetpack compose</p>