Skip to content

What is the usage of catchError()? How different is it compare to try catch? #2481

Answered by marvin-j97
PTPhongKMF asked this question in Q&A
Discussion options

You must be logged in to vote

One obvious usage is ErrorBoundary:

export function ErrorBoundary(props: {
fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
children: JSX.Element;
}): JSX.Element {
let err;
if (sharedConfig!.context && sharedConfig!.load)
err = sharedConfig.load(sharedConfig.getContextId());
const [errored, setErrored] = createSignal<any>(err, IS_DEV ? { name: "errored" } : undefined);
Errors || (Errors = new Set());
Errors.add(setErrored);
onCleanup(() => Errors.delete(setErrored));
return createMemo(
() => {
let e: any;
if ((e = err…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PTPhongKMF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants