Skip to content

Commit 6b96f58

Browse files
committed
Update error message on navigate
Test: n/a Bug: 280236412 Relnote: "The error message has been updated when navigating on a NavController with no navigation graph set." Change-Id: If06be7d4888aa654842adfdd961ce04b577ddb07
1 parent bafed9b commit 6b96f58

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

navigation/CHANGELOG.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@
1414
# Behavior Change
1515
# External Contributions
1616

17-
# Unreleased
17+
## Unreleased
18+
19+
### Bug Fixes
20+
21+
- Updated the error message and exception type when navigating on a NavController with no
22+
navigation graph set.
1823

1924
### Dependency Updates
2025

21-
* Changed dependency of Activity library from version 1.6.1 to version 1.7.1.
26+
- Changed dependency of Activity library from version 1.6.1 to version 1.7.1.
27+
2228

navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,7 @@ public open class NavController(
16051605
* @param navOptions special options for this navigation operation
16061606
* @param navigatorExtras extras to pass to the Navigator
16071607
*
1608-
* @throws IllegalStateException if there is no current navigation node
1608+
* @throws IllegalStateException if navigation graph has not been set for this NavController
16091609
* @throws IllegalArgumentException if the desired destination cannot be found from the
16101610
* current destination
16111611
*/
@@ -1622,7 +1622,10 @@ public open class NavController(
16221622
_graph
16231623
else
16241624
backQueue.last().destination
1625-
) ?: throw IllegalStateException("no current navigation node")
1625+
) ?: throw IllegalStateException(
1626+
"No current destination found. Ensure a navigation graph has been set for " +
1627+
"NavController $this."
1628+
)
16261629

16271630
@IdRes
16281631
var destId = resId

0 commit comments

Comments
 (0)