Skip to content
Permalink
Browse files

Use when() for exception handling in ContentProviderClientCompat

  • Loading branch information...
ianhanniballake committed Oct 30, 2019
1 parent 769d21f commit 3941ad160105a7f9d74d0a9e249f0080e3235d5a
@@ -53,10 +53,9 @@ class ContentProviderClientCompat private constructor(
try {
mContentProviderClient.call(method, arg, extras)
} catch (e: Exception) {
if (e is RemoteException) {
throw e
} else {
throw RemoteException(e.message)
when (e) {
is RemoteException -> throw e
else -> throw RemoteException(e.message)
}
}
}
@@ -74,10 +73,9 @@ class ContentProviderClientCompat private constructor(
mContentProviderClient.query(
url, projection, selection, selectionArgs, sortOrder)
} catch (e: Exception) {
if (e is RemoteException) {
throw e
} else {
throw RemoteException(e.message)
when (e) {
is RemoteException -> throw e
else -> throw RemoteException(e.message)
}
}
}
@@ -91,10 +89,10 @@ class ContentProviderClientCompat private constructor(
ParcelFileDescriptor.AutoCloseInputStream(this)
}
} catch (e: Exception) {
if (e is FileNotFoundException || e is RemoteException) {
throw e
} else {
throw RemoteException(e.message)
when (e) {
is FileNotFoundException -> throw e
is RemoteException -> throw e
else -> throw RemoteException(e.message)
}
}
}

0 comments on commit 3941ad1

Please sign in to comment.
You can’t perform that action at this time.