Skip to content
Snippets Groups Projects
Unverified Commit 4f1149ff authored by Daniel's avatar Daniel
Browse files

ENH: More useful error message if debug mode is disabled.

parent 906cf89a
No related branches found
No related tags found
1 merge request!3F fsm
......@@ -31,7 +31,7 @@ from lxml import etree
from caosdb.common.utils import xml2str
from caosdb.connection.connection import get_connection
from caosdb.exceptions import (AuthorizationException, ClientErrorException,
EntityDoesNotExistError)
EntityDoesNotExistError, ServerConfigurationException)
def set_server_property(key, value):
......@@ -52,9 +52,11 @@ def set_server_property(key, value):
None
"""
con = get_connection()
try:
con._form_data_request(method="POST", path="_server_properties",
params={key: value}).read()
except EntityDoesNotExistError:
raise ServerConfigurationException("Debug mode in server is probably disabled.") from None
def get_server_properties():
......@@ -68,7 +70,11 @@ def get_server_properties():
The server properties.
"""
con = get_connection()
try:
body = con._http_request(method="GET", path="_server_properties").response
except EntityDoesNotExistError:
raise ServerConfigurationException("Debug mode in server is probably disabled.") from None
xml = etree.parse(body)
props = dict()
......
......@@ -60,6 +60,13 @@ class ConfigurationException(CaosDBException):
".pycaosdb.ini. Do at least one of them exist and are they correct?")
class ServerConfigurationException(CaosDBException):
"""The server is configured in a different way than expected.
This can be for example unexpected flags or settings or missing extensions.
"""
class ClientErrorException(CaosDBException):
def __init__(self, msg, status, body):
self.status = status
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment