Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion googleapis_auth/lib/auth_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,18 @@ Future<AutoRefreshingAuthClient> clientViaApplicationDefaultCredentials({
);
}

return await clientViaMetadataServer(baseClient: baseClient);
try {
return await clientViaMetadataServer(baseClient: baseClient);
} on Exception catch (err, stack) {
Error.throwWithStackTrace(
Exception(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm...I hate losing the original exception details. I like this idea, though.

Do we have a standarding "inner error" thing somewhere here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our case the error will be a "Failed lookup" error. I'm not sure there's a lot of value.
The stacktrace is preserved, so it should point to what originally threw

I'm not sure how we'd better preserve the chain of error. I'm not aware of an official Dart solution to this problem.
In JS we have that cause field`, but not in Dart? 🤔

'Failed to load Application Default Credentials. '
'Make sure you are logged in with `firebase` or `gcloud` CLI, '
'or your code is running on Google Compute Engine/Google App Engine.',
),
stack,
);
}
}

/// Obtains oauth2 credentials and returns an authenticated HTTP client.
Expand Down