Skip to content

Commit

Permalink
Fixing redirect to not trigger errorPage (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanluiz33 authored Dec 11, 2023
1 parent 053a2ad commit 81a3dcf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"std/": "https://deno.land/std@0.204.0/",
"partytown/": "https://deno.land/x/partytown@0.4.8/",
"deco-sites/std/": "https://denopkg.com/deco-sites/std@1.22.11/",
"deco/": "https://denopkg.com/deco-cx/deco@1.47.4/"
"deco/": "https://denopkg.com/deco-cx/deco@1.47.5/"
},
"lock": false,
"tasks": {
Expand Down
16 changes: 9 additions & 7 deletions website/pages/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export function renderSection(section: Props["sections"][number]) {
return <Component {...props} />;
}

class ErrorBoundary
extends Component<{ fallback: ComponentFunc<HTMLElement> }> {
state = { error: null };
class ErrorBoundary extends // deno-lint-ignore no-explicit-any
Component<{ fallback: ComponentFunc<any> }> {
state = { error: null as Error | null };

// deno-lint-ignore no-explicit-any
static getDerivedStateFromError(error: any) {
Expand All @@ -56,7 +56,7 @@ class ErrorBoundary

render() {
if (this.state.error) {
const err = this?.state?.error as Error;
const err = this?.state?.error;
const msg = `rendering: ${this.props} ${err?.stack}`;
logger.error(
msg,
Expand All @@ -65,9 +65,11 @@ class ErrorBoundary
msg,
);
}
return this.state.error
? this.props.fallback(this.state.error)
: this.props.children;
return !this.state.error ||
(this.state.error instanceof HttpError &&
(this.state.error as HttpError).status < 400)
? this.props.children
: this.props.fallback(this.state.error);
}
}

Expand Down

0 comments on commit 81a3dcf

Please sign in to comment.