import * as React from "react"; import StackTrace from "stacktrace-js"; import {CircularProgress} from "@mui/material"; import Button from "@mui/material/Button"; class ErrorBoundary extends React.Component { constructor(props) { super(props); this.state = { error: null, info: null, stack: null }; } componentDidCatch(error, info) { this.setState({ error, info }); console.error("[ErrorBoundary] Error caught", error, info); StackTrace.fromError(error).then(stack => { console.error("[ErrorBoundary] Stacktrace fetched", stack); const stackStr = stack.map( el => { return ` at ${el.functionName} (${el.fileName}:${el.columnNumber}:${el.lineNumber})\n`; }) this.setState({ stack: stackStr }) }); } copyStack() { let stack = ""; if (this.state.stack) { stack += `Stack trace:\n${this.state.error}\n${this.state.stack}\n\n`; } stack += `Original stack trace:\n${this.state.error}\n${this.state.info.componentStack}\n\n`; navigator.clipboard.writeText(stack); } render() { if (this.state.info) { return (

Oh no, ntfy crashed 😮

This should obviously not happen. Very sorry about this.
If you have a minute, please report this on GitHub, or let us know via Discord or Matrix.

Stack trace

{this.state.stack ?
                                {this.state.error && this.state.error.toString()}{"\n"}
                                {this.state.stack}
                            
: <> Gather more info ... }
                        {this.state.error && this.state.error.toString()}
                        {this.state.info.componentStack}
                    
); } return this.props.children; } } export default ErrorBoundary;