Skip to content

Commit cc095b8

Browse files
committed
fix
1 parent 4f3aa3e commit cc095b8

File tree

2 files changed

+10
-6
lines changed
  • packages
    • neuron-ui/src/components/ErrorBoundary
    • neuron-wallet/src/controllers

2 files changed

+10
-6
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component, ErrorInfo } from 'react'
1+
import React, { Component, ErrorInfo, ReactNode } from 'react'
22
import { Stack } from 'office-ui-fabric-react'
33
import Spinner from 'widgets/Spinner'
44
import { handleViewError } from 'services/remote'
@@ -16,11 +16,10 @@ const handleError = (error: Error, errorInfo?: ErrorInfo) => {
1616
if (import.meta.env.MODE !== 'development') {
1717
window.location.reload()
1818
}
19-
return { hasError: true }
2019
}
2120

22-
class ErrorBoundary extends Component<{ children: React.ReactChild }, { hasError: boolean }> {
23-
constructor(props: { children: React.ReactChild }) {
21+
class ErrorBoundary extends Component<{ children: ReactNode }, { hasError: boolean }> {
22+
constructor(props: { children: ReactNode }) {
2423
super(props)
2524
this.state = {
2625
hasError: false,
@@ -32,7 +31,8 @@ class ErrorBoundary extends Component<{ children: React.ReactChild }, { hasError
3231
}
3332

3433
public componentDidCatch(error: Error, errorInfo: ErrorInfo) {
35-
this.setState(handleError(error, errorInfo))
34+
handleError(error, errorInfo)
35+
this.setState({ hasError: true })
3636
}
3737

3838
render() {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,11 @@ export default class ApiController {
284284
if (env.isDevMode) {
285285
console.error(error)
286286
}
287-
logger.error(JSON.parse(error))
287+
try {
288+
logger.error(JSON.parse(error))
289+
} catch (e) {
290+
logger.error(error)
291+
}
288292
})
289293

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

0 commit comments

Comments
 (0)