Thursday, 25 August 2022

How do I catch AWS Amplify errors?

If you consider the following code

  React.useEffect(() => {
    Auth.currentUserInfo()
      .then((data) => {
        if (data.username) {
          //do something with data
        }
      })
      .catch((error) => console.log('No logged in user'))
  }, [])

When I look in my console, I see all this with my console log mixed in.

[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'
}

And I get this on my device enter image description here

Neither the try/catch or catch() seem to catch the error. How can I handle the error better without it blowing up in my console and device?



from How do I catch AWS Amplify errors?

No comments:

Post a Comment