Skip to content

Commit

Permalink
transaction_sr: TransactionFileError exception to TransactionReplayError
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Mach committed Jan 6, 2021
1 parent 0bd40bd commit e648b87
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions dnf/transaction_sr.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, msg):
super(TransactionError, self).__init__(msg)


class TransactionFileError(dnf.exceptions.Error):
class TransactionReplayError(dnf.exceptions.Error):
def __init__(self, filename, errors):
"""
:param filename: The name of the transaction file being replayed
Expand All @@ -70,10 +70,10 @@ def __init__(self, filename, errors):
for error in self.errors:
msg += "\n " + str(error)

super(TransactionFileError, self).__init__(msg)
super(TransactionReplayError, self).__init__(msg)


class IncompatibleTransactionVersionError(TransactionFileError):
class IncompatibleTransactionVersionError(TransactionReplayError):
def __init__(self, filename, msg):
super(IncompatibleTransactionVersionError, self).__init__(filename, msg)

Expand All @@ -84,15 +84,15 @@ def _check_version(version, filename):
try:
major = int(major)
except ValueError as e:
raise TransactionFileError(
raise TransactionReplayError(
filename,
_('Invalid major version "{major}", number expected.').format(major=major)
)

try:
int(minor) # minor is unused, just check it's a number
except ValueError as e:
raise TransactionFileError(
raise TransactionReplayError(
filename,
_('Invalid minor version "{minor}", number expected.').format(minor=minor)
)
Expand Down Expand Up @@ -234,12 +234,12 @@ def _load_from_file(self, fn):
try:
replay_data = json.load(f)
except json.decoder.JSONDecodeError as e:
raise TransactionFileError(fn, str(e) + ".")
raise TransactionReplayError(fn, str(e) + ".")

try:
self._load_from_data(replay_data)
except TransactionError as e:
raise TransactionFileError(fn, e)
raise TransactionReplayError(fn, e)

def _load_from_data(self, data):
self._replay_data = data
Expand Down Expand Up @@ -268,7 +268,7 @@ def _verify_toplevel_json(self, replay_data):
fn = self._filename

if "version" not in replay_data:
raise TransactionFileError(fn, _('Missing key "{key}".'.format(key="version")))
raise TransactionReplayError(fn, _('Missing key "{key}".'.format(key="version")))

self._assert_type(replay_data["version"], str, "version", "string")

Expand Down Expand Up @@ -580,7 +580,7 @@ def run(self):
errors.append(e)

if errors:
raise TransactionFileError(fn, errors)
raise TransactionReplayError(fn, errors)

def post_transaction(self):
"""
Expand Down Expand Up @@ -635,4 +635,4 @@ def post_transaction(self):
pass

if errors:
raise TransactionFileError(self._filename, errors)
raise TransactionReplayError(self._filename, errors)

0 comments on commit e648b87

Please sign in to comment.