-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle thrown values that aren't
Error
instances in App router
- Loading branch information
Showing
3 changed files
with
89 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { isNotFoundError } from './not-found' | ||
import { isRedirectError } from './redirect' | ||
import { isNotFoundError, type NotFoundError } from './not-found' | ||
import { isRedirectError, type RedirectError } from './redirect' | ||
|
||
/** | ||
* Returns true if the error is a navigation signal error. These errors are | ||
* thrown by user code to perform navigation operations and interrupt the React | ||
* render. | ||
*/ | ||
export function isNextRouterError(error: any): boolean { | ||
export function isNextRouterError( | ||
error: any | ||
): error is RedirectError | NotFoundError { | ||
return isRedirectError(error) || isNotFoundError(error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters