diff --git a/app/soapbox/components/error_boundary.js b/app/soapbox/components/error_boundary.js index 2cb6b514a..83b6b8e42 100644 --- a/app/soapbox/components/error_boundary.js +++ b/app/soapbox/components/error_boundary.js @@ -10,18 +10,35 @@ export default class ErrorBoundary extends React.PureComponent { state = { hasError: false, - stackTrace: undefined, componentStack: undefined, } componentDidCatch(error, info) { this.setState({ hasError: true, - stackTrace: error.stack, + error, componentStack: info && info.componentStack, }); } + setTextareaRef = c => { + this.textarea = c; + } + + handleCopy = e => { + if (!this.textarea) return; + + this.textarea.select(); + this.textarea.setSelectionRange(0, 99999); + + document.execCommand('copy'); + } + + getErrorText = () => { + const { error, componentStack } = this.state; + return error + componentStack; + } + clearCookies = e => { localStorage.clear(); sessionStorage.clear(); @@ -34,6 +51,8 @@ export default class ErrorBoundary extends React.PureComponent { return this.props.children; } + const errorText = this.getErrorText(); + return (
@@ -43,6 +62,13 @@ export default class ErrorBoundary extends React.PureComponent {