Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jleaniz committed Feb 27, 2024
1 parent 71f2083 commit e99374d
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions turbinia/lib/google_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import google.auth
import googleapiclient.discovery

from googleapiclient.errors import HttpError

from turbinia import __version__
from turbinia import TurbiniaException

logger = logging.getLogger('turbinia')

Expand All @@ -29,11 +32,15 @@ class GCPErrorReporting:

def __init__(self):
self._credentials, self._project = self._create_credentials()
self.logging_client = googleapiclient.discovery.build(
'clouderrorreporting',
'v1beta1',
credentials=self._credentials,
)
try:
self.logging_client = googleapiclient.discovery.build(
'clouderrorreporting',
'v1beta1',
credentials=self._credentials,
)
except google.auth.exceptions.MutualTLSChannelError as exception:
raise TurbiniaException(
'Error creating Google API client: {exception}') from exception

@staticmethod
def _create_credentials() -> google.auth.credentials.Credentials:
Expand All @@ -51,11 +58,11 @@ def report(self, message, caller=None) -> None:
'lineNumber': line_number,
'functionName': function_name
}
# logger.warning(message, caller)

try:
self._send_error_report(message, report_location=report_location)
except Exception:
logger.exception('Unable to report error: %s', message)
except HttpError as exception:
logger.exception('Unable to report error: %s', exception)

def _send_error_report(self, message, report_location) -> None:
payload = {
Expand Down

0 comments on commit e99374d

Please sign in to comment.