Skip to content

Commit 83a27bb

Browse files
Optimized the exception message of Fragment
1 parent 8f83a68 commit 83a27bb

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

viewbinding-ktx/src/main/java/com/dylanc/viewbinding/Fragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class FragmentBindingProperty<VB : ViewBinding>(private val clazz: Class<VB>) :
4141
if (binding is ViewDataBinding) binding.lifecycleOwner = thisRef.viewLifecycleOwner
4242
}
4343
} catch (e: IllegalStateException) {
44-
throw IllegalStateException("The binding property has been destroyed.")
44+
throw IllegalStateException("The property of ${property.name} has been destroyed.")
4545
}
4646
}
4747

@@ -55,7 +55,7 @@ class FragmentInflateBindingProperty<VB : ViewBinding>(private val clazz: Class<
5555
binding = (clazz.getMethod("inflate", LayoutInflater::class.java).invoke(null, thisRef.layoutInflater) as VB)
5656
.also { binding -> if (binding is ViewDataBinding) binding.lifecycleOwner = thisRef.viewLifecycleOwner }
5757
} catch (e: IllegalStateException) {
58-
throw IllegalStateException("The binding property has been destroyed.")
58+
throw IllegalStateException("The property of ${property.name} has been destroyed.")
5959
}
6060
thisRef.viewLifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver {
6161
override fun onDestroy(owner: LifecycleOwner) {

viewbinding-ktx/src/main/java/com/dylanc/viewbinding/ViewBinding.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package com.dylanc.viewbinding
2020

2121
import android.view.LayoutInflater
22-
import android.view.View
2322
import android.view.ViewGroup
2423
import androidx.viewbinding.ViewBinding
2524

viewbinding-nonreflection-ktx/src/main/java/com/dylanc/viewbinding/nonreflection/Fragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class FragmentBindingDelegate<VB : ViewBinding>(private val bind: (View) -> VB)
3939
if (binding is ViewDataBinding) binding.lifecycleOwner = thisRef.viewLifecycleOwner
4040
}
4141
} catch (e: IllegalStateException) {
42-
throw IllegalStateException("The binding property has been destroyed.")
42+
throw IllegalStateException("The property of ${property.name} has been destroyed.")
4343
}
4444
return binding
4545
}
@@ -55,7 +55,7 @@ class FragmentInflateBindingDelegate<VB : ViewBinding>(private val inflate: (Lay
5555
if (binding is ViewDataBinding) binding.lifecycleOwner = thisRef.viewLifecycleOwner
5656
}
5757
} catch (e: IllegalStateException) {
58-
throw IllegalStateException("The binding property has been destroyed.")
58+
throw IllegalStateException("The property of ${property.name} has been destroyed.")
5959
}
6060
thisRef.viewLifecycleOwner.lifecycle.addObserver(object : DefaultLifecycleObserver {
6161
override fun onDestroy(owner: LifecycleOwner) {

0 commit comments

Comments
 (0)