# ReThrowCorruptionHandler

Artifact: [androidx.datastore:datastore-core](https://developer.android.com/jetpack/androidx/releases/datastore) [View Source](https://cs.android.com/search?q=file:androidx/datastore/core/handlers/ReThrowCorruptionHandler.+class:androidx.datastore.core.handlers.ReThrowCorruptionHandler) Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/datastore#1.3.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  class ReThrowCorruptionHandler<T : Any?> : CorruptionHandler<T>
  ```

*** ** * ** ***

Default corruption handler which does nothing but rethrow the exception.

## Summary

| ### Public constructors |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/datastore/core/handlers/ReThrowCorruptionHandler#ReThrowCorruptionHandler()()` | Cmn |
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/datastore/core/handlers/ReThrowCorruptionHandler#ReThrowCorruptionHandler()()` | android |
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/datastore/core/handlers/ReThrowCorruptionHandler#ReThrowCorruptionHandler()()` | N |
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/datastore/core/handlers/ReThrowCorruptionHandler#ReThrowCorruptionHandler()()` | JS |

| ### Public functions |
|---|---|---|
| `open suspend T` | `https://developer.android.com/reference/kotlin/androidx/datastore/core/handlers/ReThrowCorruptionHandler#handleCorruption(androidx.datastore.core.CorruptionException)(ex: https://developer.android.com/reference/kotlin/androidx/datastore/core/CorruptionException)` This function will be called by DataStore when it encounters corruption. | Cmn android N JS |

## Public constructors

### ReThrowCorruptionHandler

Cmn

```
<T : Any?> ReThrowCorruptionHandler()
```

### ReThrowCorruptionHandler

android

```
<T : Any?> ReThrowCorruptionHandler()
```

### ReThrowCorruptionHandler

N

```
<T : Any?> ReThrowCorruptionHandler()
```

### ReThrowCorruptionHandler

JS

```
<T : Any?> ReThrowCorruptionHandler()
```

## Public functions

### handleCorruption

Cmn android N JS

```
open suspend fun handleCorruption(ex: CorruptionException): T
```

This function will be called by DataStore when it encounters corruption. If the implementation of this function throws an exception, it will be propagated to the original call to DataStore. Otherwise, the returned data will be written to disk.

This function should not interact with any DataStore API - doing so can result in a deadlock.

| Parameters |
|---|---|
| `ex: https://developer.android.com/reference/kotlin/androidx/datastore/core/CorruptionException` | is the exception encountered when attempting to deserialize data from disk. |

| Returns |
|---|---|
| `T` | The value that DataStore should attempt to write to disk. |