@@ -7,7 +7,13 @@ import { mapStackTrace } from "sourcemapped-stacktrace"
7
7
import { Margins } from "../Margins/Margins"
8
8
import { Section } from "../Section/Section"
9
9
import { Typography } from "../Typography/Typography"
10
- import { reducer , RuntimeErrorReport , stackTraceAvailable , stackTraceUnavailable } from "./RuntimeErrorReport"
10
+ import {
11
+ createFormattedStackTrace ,
12
+ reducer ,
13
+ RuntimeErrorReport ,
14
+ stackTraceAvailable ,
15
+ stackTraceUnavailable ,
16
+ } from "./RuntimeErrorReport"
11
17
12
18
export const Language = {
13
19
title : "Coder encountered an error" ,
@@ -35,12 +41,17 @@ const ErrorStateTitle = () => {
35
41
/**
36
42
* A description for our error boundary UI
37
43
*/
38
- const ErrorStateDescription = ( ) => {
44
+ const ErrorStateDescription = ( { emailBody } : { emailBody ?: string } ) => {
39
45
const styles = useStyles ( )
40
46
return (
41
47
< Typography variant = "body2" color = "textSecondary" >
42
48
{ Language . body }
43
- < Link href = "mailto:support@coder.com" className = { styles . link } >
49
+ < Link
50
+ href = { `mailto:support@coder.com?subject=Error Report from Coder&body=${
51
+ emailBody && emailBody . replace ( / \r \n | \r | \n / g, "%0D%0A" ) // preserving line breaks
52
+ } `}
53
+ className = { styles . link }
54
+ >
44
55
{ Language . link }
45
56
</ Link >
46
57
</ Typography >
@@ -65,7 +76,15 @@ export const RuntimeErrorState: React.FC<RuntimeErrorStateProps> = ({ error }) =
65
76
return (
66
77
< Box display = "flex" flexDirection = "column" >
67
78
< Margins >
68
- < Section className = { styles . reportContainer } title = { < ErrorStateTitle /> } description = { < ErrorStateDescription /> } >
79
+ < Section
80
+ className = { styles . reportContainer }
81
+ title = { < ErrorStateTitle /> }
82
+ description = {
83
+ < ErrorStateDescription
84
+ emailBody = { createFormattedStackTrace ( reportState . error , reportState . mappedStack ) . join ( "\r\n" ) }
85
+ />
86
+ }
87
+ >
69
88
< RuntimeErrorReport error = { reportState . error } mappedStack = { reportState . mappedStack } />
70
89
</ Section >
71
90
</ Margins >
0 commit comments