()
| 54 | } |
| 55 | |
| 56 | render() { |
| 57 | const { t } = this.props |
| 58 | |
| 59 | if (!this.state.error) { |
| 60 | return this.props.children |
| 61 | } |
| 62 | |
| 63 | const errorDisplay = this.state.error |
| 64 | const componentStackDisplay = this.state.componentStack |
| 65 | |
| 66 | const version = process.env.PKG_VERSION || "unknown" |
| 67 | |
| 68 | return ( |
| 69 | <div> |
| 70 | <h2 className="text-lg font-bold mt-0 mb-2"> |
| 71 | {t("errorBoundary.title")} (v{version}) |
| 72 | </h2> |
| 73 | <p className="mb-4"> |
| 74 | {t("errorBoundary.reportText")}{" "} |
| 75 | <a href={EXTERNAL_LINKS.GITHUB_ISSUES} target="_blank" rel="noreferrer"> |
| 76 | {t("errorBoundary.githubText")} |
| 77 | </a> |
| 78 | </p> |
| 79 | <p className="mb-2">{t("errorBoundary.copyInstructions")}</p> |
| 80 | |
| 81 | <div className="mb-4"> |
| 82 | <h3 className="text-md font-bold mb-1">{t("errorBoundary.errorStack")}</h3> |
| 83 | <pre className="p-2 border rounded text-sm overflow-auto">{errorDisplay}</pre> |
| 84 | </div> |
| 85 | |
| 86 | {componentStackDisplay && ( |
| 87 | <div> |
| 88 | <h3 className="text-md font-bold mb-1">{t("errorBoundary.componentStack")}</h3> |
| 89 | <pre className="p-2 border rounded text-sm overflow-auto">{componentStackDisplay}</pre> |
| 90 | </div> |
| 91 | )} |
| 92 | </div> |
| 93 | ) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | export default withTranslation("common")(ErrorBoundary) |
no test coverage detected