当我输入错误的凭据时,我想从google auth中捕获错误。即使我尝试捕获该错误,它也只会输出意外的承诺拒绝。
我的代码:
const dialogflow = require('dialogflow');
async function listIntents(config){
try{
const intentClient = new dialogflow.IntentsClient(config);
}
catch(error){
console.log("Error Caught")
}
}
listIntents('dfdff');
错误输出:
UnhandledPromiseRejectionWarning: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
at GoogleAuth.<anonymous> (C:\Users\Hein\Desktop\telegram-bot-home\node_modules\google-auth-library\build\src\auth\googleauth.js:168:23)
at Generator.next (<anonymous>)
at fulfilled (C:\Users\Hein\Desktop\telegram-bot-home\node_modules\google-auth-library\build\src\auth\googleauth.js:19:58)
at process._tickCallback (internal/process/next_tick.js:68:7)