File tree Expand file tree Collapse file tree 2 files changed +25
-15
lines changed
web-frontend/src/main/v3/packages/ui/src/components/Error Expand file tree Collapse file tree 2 files changed +25
-15
lines changed Original file line number Diff line number Diff line change @@ -9,15 +9,14 @@ import {
99 DialogTrigger ,
1010 Separator ,
1111} from '../ui' ;
12- import * as PopoverPrimitive from '@radix-ui/react-popover' ;
1312import { ErrorLike } from '@pinpoint-fe/ui/src/constants' ;
1413import { cn } from '../../lib' ;
1514import { HighLightCode } from '../HighLightCode' ;
1615import { RxChevronDown , RxChevronUp } from 'react-icons/rx' ;
1716
1817export 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 && (
Original file line number Diff line number Diff line change 11import { ErrorLike } from '@pinpoint-fe/ui/src/constants' ;
22
33export 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} ;
You can’t perform that action at this time.
0 commit comments