Skip to content

Commit b7a5255

Browse files
committed
Update exceptions with better error messages
1 parent cdd66b1 commit b7a5255

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

investing_algorithm_framework/extensions/database_resolver.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def __get__(self, instance, owner):
108108
return None
109109

110110

111-
class Model(object):
111+
class Model:
112112
"""
113113
Standard SQL alchemy model
114114
@@ -154,7 +154,7 @@ def _flush(self):
154154
self.session.rollback()
155155
raise
156156

157-
def _repr(self, **fields: Any) -> str:
157+
def repr(self, **fields: Any) -> str:
158158
"""
159159
Helper for __repr__
160160
"""
@@ -163,6 +163,7 @@ def _repr(self, **fields: Any) -> str:
163163
at_least_one_attached_attribute = False
164164

165165
for key, field in fields.items():
166+
166167
try:
167168
field_strings.append(f'{key}={field!r}')
168169
except DetachedInstanceError:
@@ -232,7 +233,7 @@ def session(self) -> Session:
232233
return self.Session()
233234

234235
@property
235-
def model(self) -> Model:
236+
def model(self):
236237
return self._model
237238

238239
def initialize_tables(self):
@@ -352,7 +353,7 @@ def configure(self, database_config: dict = None) -> None:
352353

353354
if self.context is None:
354355
raise DatabaseOperationalException(
355-
"Context is not configured with DatabaseResolver instance"
356+
"There is no database configuration"
356357
)
357358

358359
if not self.context.config.configured:
@@ -364,12 +365,12 @@ def configure(self, database_config: dict = None) -> None:
364365
configuration = self.context.config[DATABASE_CONFIG]
365366
except Exception:
366367
raise DatabaseOperationalException(
367-
"Database configuration has no database configuration"
368+
"Context config has no database configuration"
368369
)
369370

370371
if configuration is None:
371372
raise DatabaseOperationalException(
372-
"Database configuration has no database configuration"
373+
"There is no database configuration"
373374
)
374375
try:
375376
database_type = configuration[DATABASE_TYPE]

0 commit comments

Comments
 (0)