Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# DecodeException

*** ** * ** ***

```
class DecodeException : IOException
```

|---|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) |||||
| ↳ | [kotlin.Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html) ||||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/kotlin/java/lang/Exception.html#) |||
|   |   | ↳ | [java.io.IOException](https://developer.android.com/reference/kotlin/java/io/IOException.html#) ||
|   |   |   | ↳ | [android.graphics.ImageDecoder.DecodeException](https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#) |

Information about an interrupted decode.

## Summary

| Constants ||
|---|---|
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#GAINMAP_EXTRACTION_FAILED:kotlin.Int` The extraction of the gainmap component of the image failed. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#SOURCE_EXCEPTION:kotlin.Int` An Exception was thrown reading the `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.Source`. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#SOURCE_INCOMPLETE:kotlin.Int` The encoded data was incomplete. |
| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#SOURCE_MALFORMED_DATA:kotlin.Int` The encoded data contained an error. |

| Public methods ||
|---|---|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#getError()()` Retrieve the reason that decoding was interrupted. |
| [ImageDecoder.Source](https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.Source) | `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#getSource()()` Retrieve the `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.Source` that was interrupted. |

## Constants

### GAINMAP_EXTRACTION_FAILED

Added in [API level 37.2](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val GAINMAP_EXTRACTION_FAILED: Int
```

The extraction of the gainmap component of the image failed. If the partially decoded result is returned by returning true from `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.OnPartialImageListener#onPartialImage(android.graphics.ImageDecoder.DecodeException)` there will still be a complete base image to be viewed. It is thus recommended to return the partial image and proceed with displaying it. Applications that are doing this for editing or similar may want to consider warning the user that data was lost.

    Value: 4

### SOURCE_EXCEPTION

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val SOURCE_EXCEPTION: Int
```

An Exception was thrown reading the `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.Source`.

    Value: 1

### SOURCE_INCOMPLETE

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val SOURCE_INCOMPLETE: Int
```

The encoded data was incomplete.

    Value: 2

### SOURCE_MALFORMED_DATA

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
static val SOURCE_MALFORMED_DATA: Int
```

The encoded data contained an error.

    Value: 3

## Public methods

### getError

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun getError(): Int
```

Retrieve the reason that decoding was interrupted.

If the error is `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#SOURCE_EXCEPTION:kotlin.Int`, the underlying `https://developer.android.com/reference/kotlin/java/lang/Throwable.html#` can be retrieved with `https://developer.android.com/reference/kotlin/java/lang/Throwable.html#getCause()`.

| Return ||
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html` | Value is one of the following: - `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#SOURCE_EXCEPTION:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#SOURCE_INCOMPLETE:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#SOURCE_MALFORMED_DATA:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.DecodeException#GAINMAP_EXTRACTION_FAILED:kotlin.Int` |

### getSource

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

```
fun getSource(): ImageDecoder.Source
```

Retrieve the `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.Source` that was interrupted.

This can be used for equality checking to find the Source which failed to completely decode.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/graphics/ImageDecoder.Source` | This value cannot be `null`. |