@contember/react-devbar 2.1.0-alpha.9 → 2.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/index.cjs +2 -2
- package/dist/development/index.js +1 -1
- package/dist/development/src/DevErrorManager.cjs.map +1 -1
- package/dist/development/src/DevErrorManager.js.map +1 -1
- package/dist/development/src/errorHandling.cjs +2 -22
- package/dist/development/src/errorHandling.cjs.map +1 -1
- package/dist/development/src/errorHandling.js +2 -5
- package/dist/development/src/errorHandling.js.map +1 -1
- package/dist/development/src/hooks/useCopyErrorMarkdown.cjs +101 -0
- package/dist/development/src/hooks/useCopyErrorMarkdown.cjs.map +1 -0
- package/dist/development/src/hooks/useCopyErrorMarkdown.js +101 -0
- package/dist/development/src/hooks/useCopyErrorMarkdown.js.map +1 -0
- package/dist/development/src/hooks/useParsedStacktrace.cjs.map +1 -1
- package/dist/development/src/hooks/useParsedStacktrace.js.map +1 -1
- package/dist/development/src/ui/DevBar/DevBar.cjs +15 -13
- package/dist/development/src/ui/DevBar/DevBar.cjs.map +1 -1
- package/dist/development/src/ui/DevBar/DevBar.js +15 -13
- package/dist/development/src/ui/DevBar/DevBar.js.map +1 -1
- package/dist/development/src/ui/DevError/DevError.cjs.map +1 -1
- package/dist/development/src/ui/DevError/DevError.js.map +1 -1
- package/dist/development/src/ui/DevError/DevErrorBadge.cjs +2 -2
- package/dist/development/src/ui/DevError/DevErrorBadge.cjs.map +1 -1
- package/dist/development/src/ui/DevError/DevErrorBadge.js +2 -2
- package/dist/development/src/ui/DevError/DevErrorBadge.js.map +1 -1
- package/dist/development/src/ui/DevError/DevErrorCopy.cjs +36 -0
- package/dist/development/src/ui/DevError/DevErrorCopy.cjs.map +1 -0
- package/dist/development/src/ui/DevError/DevErrorCopy.js +36 -0
- package/dist/development/src/ui/DevError/DevErrorCopy.js.map +1 -0
- package/dist/development/src/ui/DevError/DevErrorInner.cjs +26 -26
- package/dist/development/src/ui/DevError/DevErrorInner.cjs.map +1 -1
- package/dist/development/src/ui/DevError/DevErrorInner.js +26 -26
- package/dist/development/src/ui/DevError/DevErrorInner.js.map +1 -1
- package/dist/development/src/ui/DevError/DevErrorList.cjs +35 -27
- package/dist/development/src/ui/DevError/DevErrorList.cjs.map +1 -1
- package/dist/development/src/ui/DevError/DevErrorList.js +35 -27
- package/dist/development/src/ui/DevError/DevErrorList.js.map +1 -1
- package/dist/development/src/ui/DevError/StackTrace.cjs +11 -11
- package/dist/development/src/ui/DevError/StackTrace.cjs.map +1 -1
- package/dist/development/src/ui/DevError/StackTrace.js +11 -11
- package/dist/development/src/ui/DevError/StackTrace.js.map +1 -1
- package/dist/production/index.cjs +2 -2
- package/dist/production/index.js +1 -1
- package/dist/production/src/errorHandling.cjs +1 -21
- package/dist/production/src/errorHandling.cjs.map +1 -1
- package/dist/production/src/errorHandling.js +1 -4
- package/dist/production/src/errorHandling.js.map +1 -1
- package/dist/production/src/hooks/useCopyErrorMarkdown.cjs +101 -0
- package/dist/production/src/hooks/useCopyErrorMarkdown.cjs.map +1 -0
- package/dist/production/src/hooks/useCopyErrorMarkdown.js +101 -0
- package/dist/production/src/hooks/useCopyErrorMarkdown.js.map +1 -0
- package/dist/production/src/hooks/useParsedStacktrace.cjs.map +1 -1
- package/dist/production/src/hooks/useParsedStacktrace.js.map +1 -1
- package/dist/production/src/ui/DevBar/DevBar.cjs +2 -0
- package/dist/production/src/ui/DevBar/DevBar.cjs.map +1 -1
- package/dist/production/src/ui/DevBar/DevBar.js +2 -0
- package/dist/production/src/ui/DevBar/DevBar.js.map +1 -1
- package/dist/production/src/ui/DevError/DevError.cjs.map +1 -1
- package/dist/production/src/ui/DevError/DevError.js.map +1 -1
- package/dist/production/src/ui/DevError/DevErrorBadge.cjs.map +1 -1
- package/dist/production/src/ui/DevError/DevErrorBadge.js.map +1 -1
- package/dist/production/src/ui/DevError/DevErrorCopy.cjs +28 -0
- package/dist/production/src/ui/DevError/DevErrorCopy.cjs.map +1 -0
- package/dist/production/src/ui/DevError/DevErrorCopy.js +28 -0
- package/dist/production/src/ui/DevError/DevErrorCopy.js.map +1 -0
- package/dist/production/src/ui/DevError/DevErrorInner.cjs.map +1 -1
- package/dist/production/src/ui/DevError/DevErrorInner.js.map +1 -1
- package/dist/production/src/ui/DevError/DevErrorList.cjs +10 -6
- package/dist/production/src/ui/DevError/DevErrorList.cjs.map +1 -1
- package/dist/production/src/ui/DevError/DevErrorList.js +10 -6
- package/dist/production/src/ui/DevError/DevErrorList.js.map +1 -1
- package/dist/production/src/ui/DevError/StackTrace.cjs.map +1 -1
- package/dist/production/src/ui/DevError/StackTrace.js.map +1 -1
- package/dist/types/errorHandling.d.ts.map +1 -1
- package/dist/types/hooks/useCopyErrorMarkdown.d.ts +12 -0
- package/dist/types/hooks/useCopyErrorMarkdown.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/dist/types/ui/DevBar/DevBar.d.ts +1 -1
- package/dist/types/ui/DevBar/DevBar.d.ts.map +1 -1
- package/dist/types/ui/DevError/DevErrorBadge.d.ts.map +1 -1
- package/dist/types/ui/DevError/DevErrorCopy.d.ts +6 -0
- package/dist/types/ui/DevError/DevErrorCopy.d.ts.map +1 -0
- package/dist/types/ui/DevError/DevErrorInner.d.ts.map +1 -1
- package/dist/types/ui/DevError/DevErrorList.d.ts +1 -1
- package/dist/types/ui/DevError/DevErrorList.d.ts.map +1 -1
- package/dist/types/ui/DevError/StackTrace.d.ts.map +1 -1
- package/package.json +12 -11
- package/src/errorHandling.tsx +1 -8
- package/src/hooks/useCopyErrorMarkdown.ts +127 -0
- package/src/hooks/useParsedStacktrace.ts +1 -1
- package/src/index.css +27 -0
- package/src/ui/DevBar/DevBar.tsx +9 -13
- package/src/ui/DevError/DevErrorBadge.tsx +0 -1
- package/src/ui/DevError/DevErrorCopy.tsx +30 -0
- package/src/ui/DevError/DevErrorInner.tsx +26 -26
- package/src/ui/DevError/DevErrorList.tsx +25 -19
- package/src/ui/DevError/StackTrace.tsx +1 -4
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import type { ParsedStackTrace, ProcessedError } from '../ui/DevError/types'
|
|
3
|
+
|
|
4
|
+
const convertStackTraceToMarkdown = (stackTrace: ParsedStackTrace, lines: string[]) => {
|
|
5
|
+
stackTrace.forEach((frame, index) => {
|
|
6
|
+
lines.push(`**Frame ${index + 1}:**`)
|
|
7
|
+
lines.push('')
|
|
8
|
+
lines.push(`- **File:** ${frame.filename}${frame.line ? `:${frame.line}` : ''}`)
|
|
9
|
+
|
|
10
|
+
if (frame.callee) {
|
|
11
|
+
lines.push(`- **Function:** ${frame.callee}`)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
lines.push('')
|
|
15
|
+
|
|
16
|
+
if (frame.line !== undefined && frame.sourceCodeLines) {
|
|
17
|
+
lines.push('**Source Code:**')
|
|
18
|
+
lines.push('')
|
|
19
|
+
lines.push('```typescript')
|
|
20
|
+
|
|
21
|
+
frame.sourceCodeLines.forEach((codeLine, lineIndex) => {
|
|
22
|
+
const lineNumber = lineIndex + 1
|
|
23
|
+
// Show context around the error line (similar to the UI logic)
|
|
24
|
+
if (frame.line && lineNumber + 5 >= frame.line && lineNumber - 3 <= frame.line) {
|
|
25
|
+
const isErrorLine = lineNumber === frame.line
|
|
26
|
+
const marker = isErrorLine ? '>>> ' : ' '
|
|
27
|
+
lines.push(`${marker}${lineNumber.toString().padStart(3)}: ${codeLine}`)
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
lines.push('```')
|
|
32
|
+
lines.push('')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
lines.push('---')
|
|
36
|
+
lines.push('')
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const convertErrorToMarkdownRecursive = (error: ProcessedError, lines: string[], level: number) => {
|
|
41
|
+
const errorObject = error.error instanceof Error ? error.error : undefined
|
|
42
|
+
const prefix = '#'.repeat(level + 1)
|
|
43
|
+
|
|
44
|
+
if (errorObject) {
|
|
45
|
+
lines.push(`${prefix} ${errorObject.name}`)
|
|
46
|
+
lines.push('')
|
|
47
|
+
|
|
48
|
+
if (errorObject.message) {
|
|
49
|
+
lines.push(`**Message:** ${errorObject.message}`)
|
|
50
|
+
lines.push('')
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if ('details' in errorObject && (errorObject as Error & { details?: unknown }).details) {
|
|
54
|
+
lines.push(`**Details:** ${(errorObject as Error & { details: string }).details}`)
|
|
55
|
+
lines.push('')
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
lines.push(`${prefix} Unknown Error`)
|
|
59
|
+
lines.push('')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (error.parsedStackStrace) {
|
|
63
|
+
lines.push(`${'#'.repeat(level + 2)} Stack Trace`)
|
|
64
|
+
lines.push('')
|
|
65
|
+
convertStackTraceToMarkdown(error.parsedStackStrace, lines)
|
|
66
|
+
} else if (errorObject?.stack) {
|
|
67
|
+
lines.push(`${'#'.repeat(level + 2)} Stack Trace`)
|
|
68
|
+
lines.push('')
|
|
69
|
+
lines.push('```')
|
|
70
|
+
lines.push(errorObject.stack)
|
|
71
|
+
lines.push('```')
|
|
72
|
+
lines.push('')
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (error.cause) {
|
|
76
|
+
lines.push(`${'#'.repeat(level + 2)} Caused By`)
|
|
77
|
+
lines.push('')
|
|
78
|
+
convertErrorToMarkdownRecursive(error.cause, lines, level + 1)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const convertErrorToMarkdown = (error: ProcessedError, source: string): string => {
|
|
83
|
+
const lines: string[] = []
|
|
84
|
+
|
|
85
|
+
lines.push('# Contember Error Report')
|
|
86
|
+
lines.push('')
|
|
87
|
+
lines.push(`**Source:** ${source}`)
|
|
88
|
+
lines.push('')
|
|
89
|
+
|
|
90
|
+
convertErrorToMarkdownRecursive(error, lines, 1)
|
|
91
|
+
|
|
92
|
+
return lines.join('\n')
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type CopyMarkdownProps = {
|
|
96
|
+
currentError: ProcessedError
|
|
97
|
+
currentErrorSource: string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export const useCopyErrorMarkdown = ({ currentError, currentErrorSource }: CopyMarkdownProps) => {
|
|
101
|
+
const [copyStatus, setCopyStatus] = useState<'idle' | 'copying' | 'success' | 'error'>('idle')
|
|
102
|
+
|
|
103
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: intentional
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
setCopyStatus('idle')
|
|
106
|
+
}, [currentError])
|
|
107
|
+
|
|
108
|
+
const handleCopyMarkdown = async () => {
|
|
109
|
+
setCopyStatus('copying')
|
|
110
|
+
try {
|
|
111
|
+
const markdown = convertErrorToMarkdown(currentError, currentErrorSource)
|
|
112
|
+
await navigator.clipboard.writeText(markdown)
|
|
113
|
+
setCopyStatus('success')
|
|
114
|
+
} catch (err) {
|
|
115
|
+
console.error('Failed to copy markdown:', err)
|
|
116
|
+
setCopyStatus('error')
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const isClipboardSupported = !!navigator?.clipboard
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
copyStatus,
|
|
124
|
+
handleCopyMarkdown,
|
|
125
|
+
isClipboardSupported,
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -36,7 +36,7 @@ export const useProcessedError = (e: ErrorType): ProcessedError => {
|
|
|
36
36
|
cause: e instanceof Error && 'cause' in e && (e as any).cause !== undefined ? await createErrorWithStackTrace((e as any).cause) : undefined,
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
(async () => {
|
|
39
|
+
;(async () => {
|
|
40
40
|
setError(await createErrorWithStackTrace(e))
|
|
41
41
|
})()
|
|
42
42
|
}, [e])
|
package/src/index.css
CHANGED
|
@@ -235,6 +235,12 @@
|
|
|
235
235
|
overflow: auto;
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
.cui-devError-errorSource {
|
|
239
|
+
display: flex;
|
|
240
|
+
gap: 20px;
|
|
241
|
+
align-items: center;
|
|
242
|
+
}
|
|
243
|
+
|
|
238
244
|
.cui-devError-errorMessage,
|
|
239
245
|
.cui-devError-errorName,
|
|
240
246
|
.cui-devError-errorDetails {
|
|
@@ -284,6 +290,7 @@
|
|
|
284
290
|
color: #eeeeee;
|
|
285
291
|
display: flex;
|
|
286
292
|
align-items: center;
|
|
293
|
+
justify-content: space-between;
|
|
287
294
|
}
|
|
288
295
|
|
|
289
296
|
.cui-devError-causedBy {
|
|
@@ -294,6 +301,26 @@
|
|
|
294
301
|
align-items: center;
|
|
295
302
|
}
|
|
296
303
|
|
|
304
|
+
.cui-devError-copyButton {
|
|
305
|
+
background: transparent;
|
|
306
|
+
border: 1px solid #cbcbcb;
|
|
307
|
+
border-radius: 0.375rem;
|
|
308
|
+
color: #ffffff;
|
|
309
|
+
cursor: pointer;
|
|
310
|
+
font-size: 0.875rem;
|
|
311
|
+
font-weight: 500;
|
|
312
|
+
padding: 0.375rem 0.75rem;
|
|
313
|
+
transition: all 200ms;
|
|
314
|
+
display: flex;
|
|
315
|
+
align-items: center;
|
|
316
|
+
gap: 0.25rem;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.cui-devError-copyButton:hover:not(:disabled) {
|
|
320
|
+
background: #910f0f;
|
|
321
|
+
border-color: #910f0f;
|
|
322
|
+
}
|
|
323
|
+
|
|
297
324
|
.cui-devError-actions {
|
|
298
325
|
margin-left: auto;
|
|
299
326
|
display: flex;
|
package/src/ui/DevBar/DevBar.tsx
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useId,
|
|
3
|
-
useOnElementClickOutsideCallback,
|
|
4
|
-
useReferentiallyStableCallback,
|
|
5
|
-
useWindowSize,
|
|
6
|
-
} from '@contember/react-utils'
|
|
1
|
+
import { useId, useOnElementClickOutsideCallback, useReferentiallyStableCallback, useWindowSize } from '@contember/react-utils'
|
|
7
2
|
import { dataAttribute } from '@contember/utilities'
|
|
8
|
-
import { PropsWithChildren, ReactNode, useCallback, useEffect, useRef, useState } from 'react'
|
|
3
|
+
import { type PropsWithChildren, type ReactNode, useCallback, useEffect, useRef, useState } from 'react'
|
|
9
4
|
|
|
10
5
|
const className = (cls: string | null) => cls ? `cui-devBar-${cls}` : 'cui-devBar'
|
|
11
6
|
|
|
@@ -22,6 +17,7 @@ export const DevBar = ({
|
|
|
22
17
|
setExpanded(expanded => !expanded)
|
|
23
18
|
})
|
|
24
19
|
|
|
20
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: intentional
|
|
25
21
|
useEffect(() => {
|
|
26
22
|
function handleKeyDown(event: KeyboardEvent) {
|
|
27
23
|
if (event.code === 'KeyJ' && (event.ctrlKey || event.metaKey)) {
|
|
@@ -96,12 +92,10 @@ export const DevPanel = ({ heading, icon, children, preview }: DevPanelProps) =>
|
|
|
96
92
|
|
|
97
93
|
const handleClickOutside = (event: MouseEvent) => {
|
|
98
94
|
const rect = dialog.getBoundingClientRect()
|
|
99
|
-
const isInDialog =
|
|
100
|
-
rect.top
|
|
101
|
-
|
|
102
|
-
rect.left
|
|
103
|
-
event.clientX <= rect.left + rect.width
|
|
104
|
-
)
|
|
95
|
+
const isInDialog = rect.top <= event.clientY
|
|
96
|
+
&& event.clientY <= rect.top + rect.height
|
|
97
|
+
&& rect.left <= event.clientX
|
|
98
|
+
&& event.clientX <= rect.left + rect.width
|
|
105
99
|
|
|
106
100
|
if (!isInDialog) {
|
|
107
101
|
dialog.close()
|
|
@@ -126,6 +120,7 @@ export const DevPanel = ({ heading, icon, children, preview }: DevPanelProps) =>
|
|
|
126
120
|
return (
|
|
127
121
|
<div className={className('trigger')}>
|
|
128
122
|
<button
|
|
123
|
+
type="button"
|
|
129
124
|
ref={triggerRef}
|
|
130
125
|
tabIndex={0}
|
|
131
126
|
aria-haspopup="dialog"
|
|
@@ -144,6 +139,7 @@ export const DevPanel = ({ heading, icon, children, preview }: DevPanelProps) =>
|
|
|
144
139
|
<div className={className('panel-header')}>
|
|
145
140
|
<h2 className="h4">{heading}</h2>
|
|
146
141
|
<button
|
|
142
|
+
type="button"
|
|
147
143
|
onClick={handleClose}
|
|
148
144
|
className={className('close-button')}
|
|
149
145
|
aria-label="Close"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useCopyErrorMarkdown } from '../../hooks/useCopyErrorMarkdown'
|
|
2
|
+
import { ProcessedError } from './types'
|
|
3
|
+
|
|
4
|
+
export const DevErrorCopy = ({ currentError, currentErrorSource }: {
|
|
5
|
+
currentError: ProcessedError
|
|
6
|
+
currentErrorSource: string
|
|
7
|
+
}) => {
|
|
8
|
+
const { copyStatus, handleCopyMarkdown, isClipboardSupported } = useCopyErrorMarkdown({ currentError, currentErrorSource })
|
|
9
|
+
|
|
10
|
+
if (!isClipboardSupported) {
|
|
11
|
+
return null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<button
|
|
16
|
+
type="button"
|
|
17
|
+
className="cui-devError-copyButton"
|
|
18
|
+
onClick={handleCopyMarkdown}
|
|
19
|
+
disabled={copyStatus === 'copying'}
|
|
20
|
+
title="Copy current error as Markdown"
|
|
21
|
+
>
|
|
22
|
+
{{
|
|
23
|
+
success: 'Copied!',
|
|
24
|
+
copying: 'Copying...',
|
|
25
|
+
error: '❌ Copy Failed',
|
|
26
|
+
idle: 'Copy as Markdown',
|
|
27
|
+
}[copyStatus]}
|
|
28
|
+
</button>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
@@ -6,42 +6,42 @@ export interface DevErrorInnerProps {
|
|
|
6
6
|
level?: number
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
const className = (cls?: string | null) => cls ? `cui-devError-${cls}` : 'cui-devError'
|
|
11
10
|
|
|
12
11
|
export function DevErrorInner({ error, level = 1 }: DevErrorInnerProps) {
|
|
13
|
-
|
|
14
12
|
let errorObject: Error | undefined = error.error instanceof Error ? error.error : undefined
|
|
15
13
|
|
|
16
14
|
return (
|
|
17
15
|
<>
|
|
18
16
|
<div className={className('header')}>
|
|
19
|
-
{errorObject
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
{errorObject
|
|
18
|
+
? (
|
|
19
|
+
<>
|
|
20
|
+
<h1 className={className('errorName')}>{errorObject.name}</h1>
|
|
21
|
+
{error.cause && <a href={`#error-${level}`} className={className('causeLink')}>caused by ></a>}
|
|
22
|
+
{errorObject.message && <h2 className={className('errorMessage')}>{errorObject.message}</h2>}
|
|
23
|
+
{'details' in errorObject && <div className={className('errorDetails')}>{(errorObject as any).details}</div>}
|
|
24
|
+
</>
|
|
25
|
+
)
|
|
26
|
+
: <h1 className={className('errorName')}>Unknown error</h1>}
|
|
29
27
|
</div>
|
|
30
|
-
{error.parsedStackStrace ?
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<div className={className('stack-dump')}>{errorObject.stack}</div>
|
|
35
|
-
</div>
|
|
36
|
-
) : null}
|
|
37
|
-
{error.cause ? (
|
|
38
|
-
<>
|
|
39
|
-
<div className={className('causedBy')} id={`error-${level}`}>
|
|
40
|
-
Caused by
|
|
28
|
+
{error.parsedStackStrace ? <StackTrace stackTrace={error.parsedStackStrace} /> : errorObject?.stack
|
|
29
|
+
? (
|
|
30
|
+
<div className={className('stack')}>
|
|
31
|
+
<div className={className('stack-dump')}>{errorObject.stack}</div>
|
|
41
32
|
</div>
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
)
|
|
34
|
+
: null}
|
|
35
|
+
{error.cause
|
|
36
|
+
? (
|
|
37
|
+
<>
|
|
38
|
+
<div className={className('causedBy')} id={`error-${level}`}>
|
|
39
|
+
Caused by
|
|
40
|
+
</div>
|
|
41
|
+
<DevErrorInner error={error.cause} level={level + 1} />
|
|
42
|
+
</>
|
|
43
|
+
)
|
|
44
|
+
: null}
|
|
45
45
|
</>
|
|
46
46
|
)
|
|
47
47
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { DevErrorInner } from './DevErrorInner'
|
|
2
|
-
import { ProcessedError } from './types'
|
|
3
1
|
import { useEffect } from 'react'
|
|
2
|
+
import { DevErrorInner } from './DevErrorInner'
|
|
3
|
+
import type { ProcessedError } from './types'
|
|
4
|
+
import { DevErrorCopy } from './DevErrorCopy'
|
|
4
5
|
|
|
5
6
|
export interface DevErrorListProps {
|
|
6
7
|
currentError: ProcessedError
|
|
@@ -36,31 +37,36 @@ export function DevErrorList({
|
|
|
36
37
|
<div className={className()}>
|
|
37
38
|
<div className={className('in')}>
|
|
38
39
|
<div className={className('bar')}>
|
|
39
|
-
<div className={className('errorSource')}>
|
|
40
|
+
<div className={className('errorSource')}>
|
|
41
|
+
{currentErrorSource}
|
|
42
|
+
<DevErrorCopy currentError={currentError} currentErrorSource={currentErrorSource} />
|
|
43
|
+
</div>
|
|
40
44
|
<div className={className('actions')}>
|
|
41
|
-
{errorCount > 1
|
|
42
|
-
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
{errorCount > 1
|
|
46
|
+
? (
|
|
47
|
+
<div className={className('switcher')}>
|
|
48
|
+
<p className={className('errorCount')}>
|
|
49
|
+
Error {currentErrorIndex + 1} of {errorCount}
|
|
50
|
+
</p>
|
|
51
|
+
<div className={className('switcherButtons')}>
|
|
52
|
+
<button type="button" className={className('switcherButton')} onClick={onPrevious}>
|
|
53
|
+
←
|
|
54
|
+
</button>
|
|
55
|
+
<button type="button" className={className('switcherButton')} onClick={onNext}>
|
|
56
|
+
→
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
53
59
|
</div>
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
)
|
|
61
|
+
: null}
|
|
56
62
|
<div className={className('close')}>
|
|
57
|
-
<button className={className('closeButton')} onClick={onClose}>
|
|
63
|
+
<button type="button" className={className('closeButton')} onClick={onClose}>
|
|
58
64
|
✕
|
|
59
65
|
</button>
|
|
60
66
|
</div>
|
|
61
67
|
</div>
|
|
62
68
|
<div className={className('close')}>
|
|
63
|
-
<button className={className('closeButton')} onClick={onClear}>
|
|
69
|
+
<button type="button" className={className('closeButton')} onClick={onClear}>
|
|
64
70
|
Clear errors
|
|
65
71
|
</button>
|
|
66
72
|
</div>
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { ParsedStackFrame, ParsedStackTrace } from './types'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
const className = (cls?: string | null) => cls ? `cui-devError-${cls}` : 'cui-devError'
|
|
5
4
|
export const StackTrace = ({ stackTrace }: { stackTrace: ParsedStackTrace }) => {
|
|
6
5
|
return (
|
|
7
6
|
<div className={className('stack')}>
|
|
8
|
-
{stackTrace.map((it, index) =>
|
|
9
|
-
<StackFrame stackFrame={it} key={index} />
|
|
10
|
-
))}
|
|
7
|
+
{stackTrace.map((it, index) => <StackFrame stackFrame={it} key={index} />)}
|
|
11
8
|
</div>
|
|
12
9
|
)
|
|
13
10
|
}
|