Skip to content

Commit bbdf4a1

Browse files
jihea-parkclaude
andcommitted
[#noissue] Address PR review: fix type mismatch, broken link, and stack loss
- Change contentOption type from PopoverContentProps to DialogContent props - Remove unsupported collisionPadding prop from DialogContent - Conditionally render <a> only when url is present for instance - Preserve original Error stack/cause in ThrowError by rethrowing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3fdffc0 commit bbdf4a1

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

web-frontend/src/main/v3/packages/ui/src/components/Error/ErrorDetailDialog.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ import {
99
DialogTrigger,
1010
Separator,
1111
} from '../ui';
12-
import * as PopoverPrimitive from '@radix-ui/react-popover';
1312
import { ErrorLike } from '@pinpoint-fe/ui/src/constants';
1413
import { cn } from '../../lib';
1514
import { HighLightCode } from '../HighLightCode';
1615
import { RxChevronDown, RxChevronUp } from 'react-icons/rx';
1716

1817
export interface ErrorDetailDialogProps {
1918
error: Error | ErrorLike;
20-
contentOption?: PopoverPrimitive.PopoverContentProps;
19+
contentOption?: React.ComponentPropsWithoutRef<typeof DialogContent>;
2120
contentClassName?: string;
2221
}
2322

@@ -62,7 +61,6 @@ export const ErrorDetailDialog = ({
6261
</DialogTrigger>
6362
<DialogContent
6463
className={cn('max-h-[90%] overflow-auto max-w-5xl', contentClassName)}
65-
collisionPadding={16}
6664
onMouseDown={(e) => e.stopPropagation()}
6765
{...contentOption}
6866
>
@@ -75,14 +73,20 @@ export const ErrorDetailDialog = ({
7573

7674
{serverError?.instance && (
7775
<div className="flex gap-1 items-center">
78-
<a
79-
className="text-sm font-semibold text-primary hover:underline"
80-
href={serverError?.url}
81-
target="_blank"
82-
rel="noreferrer"
83-
>
84-
{serverError.instance}
85-
</a>
76+
{serverError?.url ? (
77+
<a
78+
className="text-sm font-semibold text-primary hover:underline"
79+
href={serverError.url}
80+
target="_blank"
81+
rel="noreferrer"
82+
>
83+
{serverError.instance}
84+
</a>
85+
) : (
86+
<span className="text-sm font-semibold">
87+
{serverError.instance}
88+
</span>
89+
)}
8690
</div>
8791
)}
8892
{hasMethod && (
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import { ErrorLike } from '@pinpoint-fe/ui/src/constants';
22

33
export const ThrowError = ({ error }: { error: Error | ErrorLike }) => {
4-
const err = new Error(
5-
(error as ErrorLike).detail || (error as ErrorLike).title || 'An error occurred.',
6-
) as Error;
4+
const detail = (error as ErrorLike).detail;
5+
const title = (error as ErrorLike).title;
6+
const normalizedMessage = detail || title || (error instanceof Error ? error.message : 'An error occurred.');
7+
8+
if (error instanceof Error) {
9+
error.message = normalizedMessage;
10+
throw error;
11+
}
12+
13+
const err = new Error(normalizedMessage);
714
Object.assign(err, error);
8-
err.message = (error as ErrorLike).detail || (error as ErrorLike).title || err.message;
915
throw err;
1016
};

0 commit comments

Comments
 (0)