Skip to content

Commit dce4972

Browse files
✨ Add bug report utility when DEBUG is open and application crashed.
1 parent feebc60 commit dce4972

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

src/application.tsx

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class C0VMApplication extends React.Component<{}, C0VMApplication
2727
}
2828

2929
render() {
30-
if (this.state.crashed) {
30+
if (this.state.crashed && !globalThis.DEBUG) {
3131
return <Result
3232
status="error"
3333
title="Application Crashed"
@@ -44,6 +44,57 @@ export default class C0VMApplication extends React.Component<{}, C0VMApplication
4444
</button>
4545
}
4646
/>
47+
} else if (this.state.crashed && globalThis.DEBUG) {
48+
return <Result
49+
status="error"
50+
title="Application Crashed (Debug Mode)"
51+
subTitle={<p>Please report this problem to our GitHub Repo!</p>}
52+
extra={
53+
<>
54+
<button
55+
className="base-btn main-btn"
56+
onClick={() => {
57+
globalThis.EDITOR_HIGHLIGHT_LINENUM = 0;
58+
this.setState({crashed: false, C0Runtime: undefined, PrintoutValue: ""});
59+
}}
60+
>
61+
Restore Editor Content
62+
</button>
63+
<div style={{textAlign: "left"}}>
64+
<h3>How to report?</h3>
65+
<h4>Step 1</h4>
66+
<p>Copy the application status dump below: </p>
67+
<pre id={globalThis.UI_PRINTOUT_ID}>{
68+
JSON.stringify(
69+
{
70+
ReactState: this.state,
71+
GlobalState: {
72+
exec_line: globalThis.EDITOR_HIGHLIGHT_LINENUM,
73+
breakpoints: Array.from(globalThis.EDITOR_BREAKPOINTS),
74+
configuration: {
75+
DEBUG: globalThis.DEBUG,
76+
DEBUG_DUMP_MEM: globalThis.DEBUG_DUMP_MEM,
77+
DEBUG_DUMP_STEP: globalThis.DEBUG_DUMP_STEP,
78+
MEM_POOL_SIZE: globalThis.MEM_POOL_SIZE,
79+
}
80+
}
81+
}, undefined, 4
82+
)
83+
}</pre>
84+
85+
<h4>Step 2</h4>
86+
<p>
87+
Open a new issue and paste the state dump above into issue description.
88+
</p>
89+
<a href="https://github.com/MarkChenYutian/C0VM-ts/issues" target="_blank" rel="noreferrer">
90+
<button className="base-btn main-btn">
91+
Open a New Issue
92+
</button>
93+
</a>
94+
</div>
95+
</>
96+
}
97+
/>
4798
}
4899
return (
49100
<div className="page-framework">

0 commit comments

Comments
 (0)