# Buggy code
def read_config(self, config):
    consent_config = config.get("user_consent")
    if consent_config is None:
        return
    self.user_consent_version = str(consent_config["version"])
    self.user_consent_template_dir = consent_config["template_dir"]
    self.user_consent_server_notice_content = consent_config.get(
        "server_notice_content",
    )
    self.block_events_without_consent_error = consent_config.get(
        "block_events_error",
    )
    self.user_consent_server_notice_to_guests = bool(
        consent_config.get(
            "send_server_notice_to_guests",
            False,
        )
    )
    self.user_consent_at_registration = bool(
        consent_config.get(
            "require_at_registration",
            False,
        )
    )
    self.user_consent_policy_name = consent_config.get(
        "policy_name",
        "Privacy Policy",
    )


# Traceback (ConfigError)
2019-01-28 21:17:00,100 - twisted - 242 - ERROR -  - Traceback (most recent call last):
2019-01-28 21:17:00,101 - twisted - 242 - ERROR -  -   File "/home/matrix/.synapse/lib/python2.7/site-packages/synapse/app/homeserver.py", line 394, in start
2019-01-28 21:17:00,101 - twisted - 242 - ERROR -  -     hs.start_listening()
2019-01-28 21:17:00,101 - twisted - 242 - ERROR -  -   File "/home/matrix/.synapse/lib/python2.7/site-packages/synapse/app/homeserver.py", line 245, in start_listening
2019-01-28 21:17:00,101 - twisted - 242 - ERROR -  -     self._listener_http(config, listener)
2019-01-28 21:17:00,102 - twisted - 242 - ERROR -  -   File "/home/matrix/.synapse/lib/python2.7/site-packages/synapse/app/homeserver.py", line 101, in _listener_http
2019-01-28 21:17:00,102 - twisted - 242 - ERROR -  -     name, res.get("compress", False),
2019-01-28 21:17:00,102 - twisted - 242 - ERROR -  -   File "/home/matrix/.synapse/lib/python2.7/site-packages/synapse/app/homeserver.py", line 183, in _configure_named_resource
2019-01-28 21:17:00,102 - twisted - 242 - ERROR -  -     consent_resource = ConsentResource(self)
2019-01-28 21:17:00,102 - twisted - 242 - ERROR -  -   File "/home/matrix/.synapse/local/lib/python2.7/site-packages/synapse/rest/consent/consent_resource.py", line 111, in __init__
2019-01-28 21:17:00,103 - twisted - 242 - ERROR -  -     consent_template_directory,
2019-01-28 21:17:00,103 - twisted - 242 - ERROR -  - ConfigError: Could not find template directory '/res/templates/privacy'
2019-01-28 21:17:00,104 - synapse.handlers.deactivate_account - 144 - INFO - user_parter_loop-0 - User parter finished: stopping
2019-01-28 21:17:00,111 - synapse.metrics - 374 - INFO -  - Collecting gc 0
2019-01-28 21:17:00,144 - twisted - 242 - CRITICAL -  - Unhandled error in Deferred:
2019-01-28 21:17:00,145 - twisted - 242 - CRITICAL -  -
Traceback (most recent call last):
File "/home/matrix/.synapse/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
result = g.send(result)
File "/home/matrix/.synapse/lib/python2.7/site-packages/synapse/app/homeserver.py", line 407, in start
sys.exit(1)
SystemExit: 1

# Fixed code
def read_config(self, config):
    consent_config = config.get("user_consent")
    if consent_config is None:
        return
    self.user_consent_version = str(consent_config["version"])
    self.user_consent_template_dir = self.abspath(consent_config["template_dir"])
    if not path.isdir(self.user_consent_template_dir):
        raise ConfigError(
            "Could not find template directory '%s'"
            % (self.user_consent_template_dir,),
        )
    self.user_consent_server_notice_content = consent_config.get(
        "server_notice_content",
    )
    self.block_events_without_consent_error = consent_config.get(
        "block_events_error",
    )
    self.user_consent_server_notice_to_guests = bool(
        consent_config.get(
            "send_server_notice_to_guests",
            False,
        )
    )
    self.user_consent_at_registration = bool(
        consent_config.get(
            "require_at_registration",
            False,
        )
    )
    self.user_consent_policy_name = consent_config.get(
        "policy_name",
        "Privacy Policy",
    )