# 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)

*** ** * ** ***


```
public final class ReThrowCorruptionHandler<T extends Object> implements CorruptionHandler<@NonNull T>
```

<br />

*** ** * ** ***

Default corruption handler which does nothing but rethrow the exception.

## Summary

| ### Public constructors |
|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/datastore/core/handlers/ReThrowCorruptionHandler#ReThrowCorruptionHandler()()` |
| `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/datastore/core/handlers/ReThrowCorruptionHandler#ReThrowCorruptionHandler()()` |

| ### Public methods |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T` | `https://developer.android.com/reference/androidx/datastore/core/handlers/ReThrowCorruptionHandler#handleCorruption(androidx.datastore.core.CorruptionException)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/core/CorruptionException ex)` This function will be called by DataStore when it encounters corruption. |

## Public constructors

### ReThrowCorruptionHandler

```
public <T extends Object> ReThrowCorruptionHandler()
```

### ReThrowCorruptionHandler

```
public <T extends Object> ReThrowCorruptionHandler()
```

## Public methods

### handleCorruption

```
public @NonNull T handleCorruption(@NonNull CorruptionException ex)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/datastore/core/CorruptionException ex` | is the exception encountered when attempting to deserialize data from disk. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T` | The value that DataStore should attempt to write to disk. |