blob: f5d33e8f50191740e69baf966af67f02c412d670 (
plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
import React from 'react'
import Center from './center'
import Area from './area'
import { Modal } from 'react-bootstrap'
import App from 'app'
class ErrorMessage extends React.Component {
static get defaultProps() {return{
message: null,
stack: null
}}
constructor(props) {
super(props)
}
render() {
let stack = null
if (this.props.stack) {
stack = <ul>
{this.props.stack.split("\n").slice(0,10).map(i =>
<li>{i}</li>
)}
</ul>
}
return(
<div>
<p>{this.props.message}</p>
{stack}
</div>
)
}
}
export default class ErrorPanel extends React.Component {
constructor(props) {
super(props)
}
hide() {
App.hideError()
}
render () {
var error_msg = null
var error = this.props.error
console.log(error)
if (error.error) {
error = error
} else if (error.reason) {
error = error.reason
}
if (error.stack && error.message) {
error_msg = <ErrorMessage message={error.message} stack={error.stack} />
} else if (error.message) {
error_msg = <ErrorMessage message={error.message} />
} else {
error_msg = <ErrorMessage message={error.toString()} />
}
return (
<Modal show={true} onHide={this.hide.bind(this)}>
<Modal.Header closeButton>
<Modal.Title>Error</Modal.Title>
</Modal.Header>
<Modal.Body>
{error_msg}
</Modal.Body>
</Modal>
)
}
}
|