Ash*_*own 8 javascript typescript reactjs react-native aws-amplify
如果您考虑以下代码
  React.useEffect(() => {
    Auth.currentUserInfo()
      .then((data) => {
        if (data.username) {
          //do something with data
        }
      })
      .catch((error) => console.log('No logged in user'))
  }, [])
当我查看控制台时,我看到所有这些都与控制台日志混合在一起。
[ERROR] 14:14.682 AuthClass - No current user
at node_modules/@aws-amplify/core/lib-esm/Logger/ConsoleLogger.js:115:9 in prototype._log
at node_modules/@aws-amplify/core/lib-esm/Logger/ConsoleLogger.js:192:18 in <anonymous>
at node_modules/@aws-amplify/auth/lib-esm/Auth.js:2097:38 in user.confirmPassword$argument_2.onFailure
No logged in user
Error: ENOENT: no such file or directory, open '/Users/XXXXX/react-native-discord/http:/192.168.50.85:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&strict=false&minify=false'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at getCodeFrame (/Users/XXXXX/react-native-discord/node_modules/metro/src/Server.js:949:18)
    at Server._symbolicate (/Users/XXXXX/react-native-discord/node_modules/metro/src/Server.js:1022:22)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Server._processRequest (/Users/XXXXX/react-native-discord/node_modules/metro/src/Server.js:429:7) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/Users/XXXXX/react-native-discord/http:/192.168.50.85:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&strict=false&minify=false'
}
Error: ENOENT: no such file or directory, open '/Users/XXXXX/react-native-discord/http:/192.168.50.85:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&strict=false&minify=false'
    at Object.openSync (node:fs:585:3)
    at Object.readFileSync (node:fs:453:35)
    at getCodeFrame (/Users/XXXXX/react-native-discord/node_modules/metro/src/Server.js:949:18)
    at Server._symbolicate (/Users/XXXXX/react-native-discord/node_modules/metro/src/Server.js:1022:22)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Server._processRequest (/Users/XXXXX/react-native-discord/node_modules/metro/src/Server.js:429:7) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/Users/XXXXX/react-native-discord/http:/192.168.50.85:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&strict=false&minify=false'
}
try/catch或似乎都没有catch()捕获错误。如何更好地处理错误而不使其在我的控制台和设备中爆炸?
| 归档时间: | 
 | 
| 查看次数: | 1673 次 | 
| 最近记录: |