Check dependencies on setup in the nicer way. (#5989)

This commit is contained in:
Jorik Schellekens 2019-09-11 14:00:37 +01:00 committed by GitHub
parent 3505ffcda7
commit 6604b64fae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 28 deletions

View file

@ -16,11 +16,9 @@
import attr
from ._base import Config, ConfigError
from synapse.python_dependencies import DependencyException, check_requirements
MISSING_SENTRY = """Missing sentry-sdk library. This is required to enable sentry
integration.
"""
from ._base import Config, ConfigError
@attr.s
@ -51,9 +49,9 @@ class MetricsConfig(Config):
self.sentry_enabled = "sentry" in config
if self.sentry_enabled:
try:
import sentry_sdk # noqa F401
except ImportError:
raise ConfigError(MISSING_SENTRY)
check_requirements("sentry")
except DependencyException as e:
raise ConfigError(e.message)
self.sentry_dsn = config["sentry"].get("dsn")
if not self.sentry_dsn: