Skip to content

Commit

Permalink
Better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Roba1993 committed Dec 21, 2023
1 parent d4582c4 commit 304a6a5
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions packages/yew-router/src/navigator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,25 +92,23 @@ impl Navigator {
}

/// Same as `.push()` but affix the queries to the end of the route.
pub fn push_with_query<R, Q>(&self, route: &R, query: Q) -> NavigationResult<()>
pub fn push_with_query<R, Q>(&self, route: &R, query: Q) -> Result<(), Q::Error>
where
R: Routable,
Q: ToQuery,
HistoryError: From<<Q as ToQuery>::Error>
{
Ok(self.inner
.push_with_query(self.prefix_basename(&route.to_path()), query)?)
self.inner
.push_with_query(self.prefix_basename(&route.to_path()), query)
}

/// Same as `.replace()` but affix the queries to the end of the route.
pub fn replace_with_query<R, Q>(&self, route: &R, query: Q) -> NavigationResult<()>
pub fn replace_with_query<R, Q>(&self, route: &R, query: Q) -> Result<(), Q::Error>
where
R: Routable,
Q: ToQuery,
HistoryError: From<<Q as ToQuery>::Error>
{
Ok(self.inner
.replace_with_query(self.prefix_basename(&route.to_path()), query)?)
self.inner
.replace_with_query(self.prefix_basename(&route.to_path()), query)
}

/// Same as `.push_with_state()` but affix the queries to the end of the route.
Expand All @@ -119,15 +117,14 @@ impl Navigator {
route: &R,
query: Q,
state: T,
) -> NavigationResult<()>
) -> Result<(), Q::Error>
where
R: Routable,
Q: ToQuery,
T: 'static,
HistoryError: From<<Q as ToQuery>::Error>
{
Ok(self.inner
.push_with_query_and_state(self.prefix_basename(&route.to_path()), query, state)?)
self.inner
.push_with_query_and_state(self.prefix_basename(&route.to_path()), query, state)
}

/// Same as `.replace_with_state()` but affix the queries to the end of the route.
Expand All @@ -136,18 +133,17 @@ impl Navigator {
route: &R,
query: Q,
state: T,
) -> NavigationResult<()>
) -> Result<(), Q::Error>
where
R: Routable,
Q: ToQuery,
T: 'static,
HistoryError: From<<Q as ToQuery>::Error>
{
Ok(self.inner.replace_with_query_and_state(
self.inner.replace_with_query_and_state(
self.prefix_basename(&route.to_path()),
query,
state,
)?)
)
}

/// Returns the Navigator kind.
Expand Down

0 comments on commit 304a6a5

Please sign in to comment.