| 35 | }; |
| 36 | |
| 37 | render() { |
| 38 | const { message, description, children } = this.props; |
| 39 | const { error, info } = this.state; |
| 40 | const componentStack = |
| 41 | info && info.componentStack ? info.componentStack : null; |
| 42 | const errorMessage = |
| 43 | typeof message === 'undefined' ? (error || '').toString() : message; |
| 44 | const errorDescription = |
| 45 | typeof description === 'undefined' ? componentStack : description; |
| 46 | |
| 47 | if (error) { |
| 48 | return ( |
| 49 | <Problem |
| 50 | text={ |
| 51 | <> |
| 52 | <h3>{t('页面出现了一些问题')}</h3> |
| 53 | <p title={errorDescription ?? ''}>{errorMessage}</p> |
| 54 | <Button size="small" onClick={this.reset}> |
| 55 | {t('重试')} |
| 56 | </Button> |
| 57 | </> |
| 58 | } |
| 59 | /> |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | return children; |
| 64 | } |
| 65 | } |