Skip to content

Commit f43dbb3

Browse files
authored
Allow uses of Try with nullable error types (Try<S, F?>) (#546)
1 parent 42ca231 commit f43dbb3

File tree

1 file changed

+3
-3
lines changed
  • readium/shared/src/main/java/org/readium/r2/shared/util

1 file changed

+3
-3
lines changed

readium/shared/src/main/java/org/readium/r2/shared/util/Try.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public sealed class Try<out Success, out Failure> {
6868
public inline fun <F> mapFailure(transform: (value: Failure) -> F): Try<Success, F> =
6969
when (this) {
7070
is Try.Success -> success(value)
71-
is Try.Failure -> failure(transform(failureOrNull()!!))
71+
is Try.Failure -> failure(transform(failureOrNull()))
7272
}
7373

7474
/**
@@ -81,7 +81,7 @@ public sealed class Try<out Success, out Failure> {
8181
): R =
8282
when (this) {
8383
is Try.Success -> onSuccess(value)
84-
is Try.Failure -> onFailure(failureOrNull()!!)
84+
is Try.Failure -> onFailure(failureOrNull())
8585
}
8686

8787
/**
@@ -98,7 +98,7 @@ public sealed class Try<out Success, out Failure> {
9898
* Returns the original [Try] unchanged.
9999
*/
100100
public inline fun onFailure(action: (exception: Failure) -> Unit): Try<Success, Failure> {
101-
if (this is Try.Failure) action(failureOrNull()!!)
101+
if (this is Try.Failure) action(failureOrNull())
102102
return this
103103
}
104104
}

0 commit comments

Comments
 (0)