lx-music-mobile-mod/src/utils/errorHandle.js

27 lines
781 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Alert } from 'react-native'
import { setJSExceptionHandler, setNativeExceptionHandler } from 'react-native-exception-handler'
const errorHandler = (e, isFatal) => {
if (isFatal) {
Alert.alert(
'💥Unexpected error occurred💥',
`
应用出bug了😭已崩溃💥以下是错误异常信息请截图通过企鹅群或者GitHub反馈现在应用将会关闭请自行重新启动
Error:
${isFatal ? 'Fatal:' : ''} ${e.name} ${e.message}
`,
[{
text: '关闭 (Close)',
}],
)
} else {
console.log(e) // So that we can see it in the ADB logs in case of Android if needed
}
}
setJSExceptionHandler(errorHandler)
setNativeExceptionHandler((errorString) => {
console.error('+++++', errorString, '+++++')
})