Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
QuinnDamerell committed Jan 9, 2025
1 parent 1209f53 commit 05ea5a8
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions homeway/homeway/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import time
import traceback

import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.integrations.threading import ThreadingIntegration
# import sentry_sdk
# from sentry_sdk.integrations.logging import LoggingIntegration
# from sentry_sdk.integrations.threading import ThreadingIntegration

from .exceptions import NoSentryReportException

Expand Down Expand Up @@ -72,7 +72,8 @@ def Setup(versionString:str, distType:str, isDevMode:bool = False):

@staticmethod
def SetPluginId(pluginId:str):
sentry_sdk.set_context("homeway", { "plugin-id": pluginId })
#sentry_sdk.set_context("homeway", { "plugin-id": pluginId })
pass


@staticmethod
Expand Down Expand Up @@ -102,14 +103,14 @@ def LogError(msg:str, extras:dict = None) -> None:
if Sentry._Logger is None:
return
Sentry._Logger.error(f"Sentry Error: {msg}")
# Never send in dev mode, as Sentry will not be setup.
if Sentry.IsSentrySetup and Sentry.IsDevMode is False:
with sentry_sdk.push_scope() as scope:
scope.set_level("error")
if extras is not None:
for key, value in extras.items():
scope.set_extra(key, value)
sentry_sdk.capture_message(msg)
# # Never send in dev mode, as Sentry will not be setup.
# if Sentry.IsSentrySetup and Sentry.IsDevMode is False:
# with sentry_sdk.push_scope() as scope:
# scope.set_level("error")
# if extras is not None:
# for key, value in extras.items():
# scope.set_extra(key, value)
# sentry_sdk.capture_message(msg)


# Logs and reports an exception.
Expand Down Expand Up @@ -138,16 +139,16 @@ def _handleException(msg:str, exception:Exception, sendException:bool, extras:di
exceptionClassType = exception.__class__.__name__
Sentry._Logger.error(msg + "; "+str(exceptionClassType)+" Exception: " + str(exception) + "; "+str(tb))

# We have a special exception that we can throw but we won't report it to sentry.
# See the class for details.
if isinstance(exception, NoSentryReportException):
return

# Never send in dev mode, as Sentry will not be setup.
if Sentry.IsSentrySetup and sendException and Sentry.IsDevMode is False:
with sentry_sdk.push_scope() as scope:
scope.set_extra("Exception Message", msg)
if extras is not None:
for key, value in extras.items():
scope.set_extra(key, value)
sentry_sdk.capture_exception(exception)
# # We have a special exception that we can throw but we won't report it to sentry.
# # See the class for details.
# if isinstance(exception, NoSentryReportException):
# return

# # Never send in dev mode, as Sentry will not be setup.
# if Sentry.IsSentrySetup and sendException and Sentry.IsDevMode is False:
# with sentry_sdk.push_scope() as scope:
# scope.set_extra("Exception Message", msg)
# if extras is not None:
# for key, value in extras.items():
# scope.set_extra(key, value)
# sentry_sdk.capture_exception(exception)

0 comments on commit 05ea5a8

Please sign in to comment.