diff options
| author | Joshua Harlow <harlowja@yahoo-inc.com> | 2014-03-24 12:32:56 -0700 |
|---|---|---|
| committer | Joshua Harlow <harlowja@gmail.com> | 2014-03-24 20:42:30 -0700 |
| commit | a570aead532bb2c247ad53896a3e66d644a58489 (patch) | |
| tree | e5a9427d2de2045fc06ac1a1a794b22465dae977 /taskflow/persistence/backends/impl_sqlalchemy.py | |
| parent | 7accd01224ed7b982a599e9fb3f899450e2c28b5 (diff) | |
| download | taskflow-a570aead532bb2c247ad53896a3e66d644a58489.tar.gz | |
Adjust the exception hierachy
Group the exceptions into the following groups
* Storage
* Jobs
* Execution
* Other (wrapped failure here)
This grouping makes it easier to understand where
one type of exception should be used vs using another
type of exception.
Backwards incompatible changes:
* StorageError -> StorageFailure
* AlreadyExists -> Duplicate
* WrappedFailure now inherits from Exception
and not directly from TaskFlowException since it
wraps arbitrary other exceptions and is not
specific to taskflow.
Cleanups:
* JobNotFound -> NotFound
* EmptyFlow -> Empty
* JobAlreadyExists -> AlreadyExists
* InvariantViolation (X)
* ConnectionFailure (X)
Change-Id: I0e1e81b513fbbc7adb8bfaa1244993e345ab70d3
Diffstat (limited to 'taskflow/persistence/backends/impl_sqlalchemy.py')
| -rw-r--r-- | taskflow/persistence/backends/impl_sqlalchemy.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/taskflow/persistence/backends/impl_sqlalchemy.py b/taskflow/persistence/backends/impl_sqlalchemy.py index fd91fdd..c61c357 100644 --- a/taskflow/persistence/backends/impl_sqlalchemy.py +++ b/taskflow/persistence/backends/impl_sqlalchemy.py @@ -308,14 +308,14 @@ class Connection(base.Connection): return functor(session, *args, **kwargs) except sa_exc.SQLAlchemyError as e: LOG.exception('Failed running database session') - raise exc.StorageError("Storage backend internal error", e) + raise exc.StorageFailure("Storage backend internal error", e) def _make_session(self): try: return self._session_maker() except sa_exc.SQLAlchemyError as e: LOG.exception('Failed creating database session') - raise exc.StorageError("Failed creating database session", e) + raise exc.StorageFailure("Failed creating database session", e) def upgrade(self): try: @@ -332,7 +332,7 @@ class Connection(base.Connection): migration.db_sync(conn) except sa_exc.SQLAlchemyError as e: LOG.exception('Failed upgrading database version') - raise exc.StorageError("Failed upgrading database version", e) + raise exc.StorageFailure("Failed upgrading database version", e) def _clear_all(self, session): # NOTE(harlowja): due to how we have our relationship setup and @@ -342,7 +342,7 @@ class Connection(base.Connection): return session.query(models.LogBook).delete() except sa_exc.DBAPIError as e: LOG.exception('Failed clearing all entries') - raise exc.StorageError("Failed clearing all entries", e) + raise exc.StorageFailure("Failed clearing all entries", e) def clear_all(self): return self._run_in_session(self._clear_all) @@ -377,7 +377,7 @@ class Connection(base.Connection): session.delete(lb) except sa_exc.DBAPIError as e: LOG.exception('Failed destroying logbook') - raise exc.StorageError("Failed destroying logbook %s" % lb_id, e) + raise exc.StorageFailure("Failed destroying logbook %s" % lb_id, e) def destroy_logbook(self, book_uuid): return self._run_in_session(self._destroy_logbook, lb_id=book_uuid) @@ -398,7 +398,7 @@ class Connection(base.Connection): return _convert_lb_to_external(lb_m) except sa_exc.DBAPIError as e: LOG.exception('Failed saving logbook') - raise exc.StorageError("Failed saving logbook %s" % lb.uuid, e) + raise exc.StorageFailure("Failed saving logbook %s" % lb.uuid, e) def save_logbook(self, book): return self._run_in_session(self._save_logbook, lb=book) @@ -410,7 +410,8 @@ class Connection(base.Connection): return _convert_lb_to_external(lb) except sa_exc.DBAPIError as e: LOG.exception('Failed getting logbook') - raise exc.StorageError("Failed getting logbook %s" % book_uuid, e) + raise exc.StorageFailure("Failed getting logbook %s" % book_uuid, + e) def get_logbooks(self): session = self._make_session() @@ -419,7 +420,7 @@ class Connection(base.Connection): books = [_convert_lb_to_external(lb) for lb in raw_books] except sa_exc.DBAPIError as e: LOG.exception('Failed getting logbooks') - raise exc.StorageError("Failed getting logbooks", e) + raise exc.StorageFailure("Failed getting logbooks", e) for lb in books: yield lb |
