Properly inline tryOrNull() (#1003)
Nullable params can't be inlined, default empty lambdas are therefore preferred.
This commit is contained in:
parent
784b84d1e8
commit
2a59e6ae78
1 changed files with 2 additions and 2 deletions
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
package io.element.android.libraries.core.data
|
||||
|
||||
inline fun <A> tryOrNull(noinline onError: ((Throwable) -> Unit)? = null, operation: () -> A): A? {
|
||||
inline fun <A> tryOrNull(onError: ((Throwable) -> Unit) = { }, operation: () -> A): A? {
|
||||
return try {
|
||||
operation()
|
||||
} catch (any: Throwable) {
|
||||
onError?.invoke(any)
|
||||
onError.invoke(any)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue