Skip to content

Commit 4f3aa3e

Browse files
committed
feat: Add UI crash logs
1 parent 0d4c967 commit 4f3aa3e

File tree

2 files changed

+14
-5
lines changed
  • packages
    • neuron-ui/src/components/ErrorBoundary
    • neuron-wallet/src/controllers

2 files changed

+14
-5
lines changed

packages/neuron-ui/src/components/ErrorBoundary/index.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
import React, { Component } from 'react'
1+
import React, { Component, ErrorInfo } from 'react'
22
import { Stack } from 'office-ui-fabric-react'
33
import Spinner from 'widgets/Spinner'
44
import { handleViewError } from 'services/remote'
55

6-
const handleError = (error: Error) => {
7-
handleViewError(error.toString())
6+
const handleError = (error: Error, errorInfo?: ErrorInfo) => {
7+
handleViewError(
8+
JSON.stringify([
9+
`UI crash: ${error.message}`,
10+
{
11+
stack: error.stack,
12+
componentStack: errorInfo?.componentStack || 'N/A',
13+
},
14+
])
15+
)
816
if (import.meta.env.MODE !== 'development') {
917
window.location.reload()
1018
}
@@ -23,8 +31,8 @@ class ErrorBoundary extends Component<{ children: React.ReactChild }, { hasError
2331
return handleError(error)
2432
}
2533

26-
public componentDidCatch(error: Error) {
27-
this.setState(handleError(error))
34+
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
35+
this.setState(handleError(error, errorInfo))
2836
}
2937

3038
render() {

packages/neuron-wallet/src/controllers/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ export default class ApiController {
284284
if (env.isDevMode) {
285285
console.error(error)
286286
}
287+
logger.error(JSON.parse(error))
287288
})
288289

289290
handle('set-locale', async (_, locale: Locale) => {

0 commit comments

Comments
 (0)