-
Notifications
You must be signed in to change notification settings - Fork 342
/
RuntimeError.js
60 lines (48 loc) · 1.61 KB
/
RuntimeError.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React from 'react'
import PropTypes from 'prop-types'
import styles from './RuntimeError.css'
export const getGitHubReportUrl = ({ title, body }) => {
let baseUrl = 'https://github.com/WorldBrain/WebMemex/issues/new?'
if (title) {
baseUrl += `title=${title}&`
}
if (body) {
baseUrl += `body=${body}&`
}
return baseUrl
}
const Output = ({ children, className }) => <pre className={className}><code>{children}</code></pre>
Output.propTypes = {
children: PropTypes.string.isRequired,
className: PropTypes.string.isRequired,
}
const RuntimeError = ({ stack, message }) => (
<div className={styles.main}>
<p className={styles.message}>
The extension page has crashed. Please reload the extension page.
</p>
<a
className={styles.reportBtn}
href={getGitHubReportUrl({ title: `Runtime error: "${message}"` })}
rel='noopener noreferrer'
target='_blank'
>
Report issue
</a>
<div className={styles.error}>
{message && [
<h1 key='head' className={styles.errorHeading}>Error message:</h1>,
<Output key='output' className={styles.errorMessage}>{message}</Output>,
]}
{stack && [
<h1 key='head' className={styles.errorHeading}>Error stack:</h1>,
<Output key='output' className={styles.errorMessage}>{stack}</Output>,
]}
</div>
</div>
)
RuntimeError.propTypes = {
stack: PropTypes.string,
message: PropTypes.string,
}
export default RuntimeError