Skip to content

Commit

Permalink
Only catch specific exceptions
Browse files Browse the repository at this point in the history
don't swallow everything
  • Loading branch information
Anthchirp committed Jul 1, 2019
1 parent 1ce4844 commit 08541ea
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions datablock.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ def __init__(self, imagesets):
def append(self, imageset):
""" Add an imageset to the block. """
if self._format_class is None:
try:
self._format_class = imageset.get_format_class()
except Exception:
pass
self._format_class = imageset.get_format_class()
else:
assert self._format_class == imageset.get_format_class()
self._imagesets.append(imageset)
Expand Down Expand Up @@ -471,9 +468,12 @@ def __init__(

# A function to append or create a new datablock
def append_to_datablocks(iset):
try:
self.datablocks[-1].append(iset)
except Exception:
if self.datablocks:
try:
self.datablocks[-1].append(iset)
except AssertionError:
self.datablocks.append(DataBlock([iset]))
else:
self.datablocks.append(DataBlock([iset]))
if verbose:
print("Added imageset to datablock %d" % (len(self.datablocks) - 1))
Expand Down Expand Up @@ -950,7 +950,7 @@ def __init__(self, imagesets):
for imageset in imagesets:
try:
self.datablocks[-1].append(imageset)
except Exception:
except (IndexError, AssertionError):
self.datablocks.append(DataBlock([imageset]))


Expand Down Expand Up @@ -1080,7 +1080,7 @@ def from_pickle_file(filename):

@staticmethod
def from_imageset(imagesets):
""" Load a datablock from an imageset of list of imagesets. """
""" Load a datablock from a list of imagesets. """
importer = DataBlockImageSetImporter(imagesets)
return importer.datablocks

Expand Down

0 comments on commit 08541ea

Please sign in to comment.