Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show error tag in local preview #916

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/ui/app/src/components/FernErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useRouter } from "next/router";
import React, { PropsWithChildren, ReactElement, useEffect } from "react";
import { ErrorBoundary, FallbackProps } from "react-error-boundary";
import { captureSentryError, captureSentryErrorMessage } from "../analytics/sentry";
import { useLocalPreviewContext } from "../contexts/LocalPreviewContext";
import { FernButton } from "./FernButton";

export declare interface FernErrorBoundaryProps {
Expand Down Expand Up @@ -34,6 +35,7 @@ export function FernErrorTag({
reset?: () => void;
resetErrorBoundary?: () => void;
}): ReactElement | null {
const { isLocalPreview } = useLocalPreviewContext();
useEffect(() => {
// eslint-disable-next-line no-console
console.error(error);
Expand All @@ -45,8 +47,11 @@ export function FernErrorTag({
"An unknown UI error occurred. This could be a critical user-facing error that should be investigated.",
});
}, [component, error, errorDescription]);
// TODO: render this error in the UI if in URL-preview, staging, dev, or local-preview model.
if (showError) {

// if local preview, always show the error tag for markdown errors
const showMarkdownError = isLocalPreview && component === "MdxErrorBoundary";

if (showError || showMarkdownError) {
return (
<div className={clsx(className ?? "my-4")}>
<span className="t-danger inline-flex items-center gap-2 rounded-full bg-tag-danger px-2">
Expand Down
Loading