Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise KeyError instead of NoSuchNodeError #10

Closed
orbeckst opened this issue Jan 29, 2015 · 1 comment
Closed

raise KeyError instead of NoSuchNodeError #10

orbeckst opened this issue Jan 29, 2015 · 1 comment

Comments

@orbeckst
Copy link
Contributor

I like using selections (and everything else) in a pythonic fashion (i.e. if it looks like a dict it should mostly behave like one even if under the hood it's all HDF5). One strength of MDS is hiding all the bookkeeping.

Therefore, it is annoying if a non-existent, say, selection raises NoSuchNodeError (no idea what kind of exception this is) when I tried

try:
   sel = self.sim.selections[name]
except KeyError:
   # do something about it because selection 'name' is not stored in the sim

because from the syntax I expected to get a KeyError.

@dotsdl
Copy link
Member

dotsdl commented Feb 3, 2015

Thanks for filing this issue. Raising exceptions at the level of the frontend (tags, categories, selections) that reflect what is failing at that level is one of the rough edges I hope we can smooth out sooner than later. As you noticed, many of these components raise exception at the level of PyTables, and they are not caught and re-raised in more meaningful ways.

@dotsdl dotsdl added the bug label Feb 3, 2015
@dotsdl dotsdl modified the milestones: .5.0, 0.5.0 Feb 3, 2015
dotsdl added a commit that referenced this issue Jun 21, 2015
Containers and their aggregators should be able to work with different
backends, which may very well not be PyTables files. To make this
possible, we need to catch PyTables-specific exceptions at the File
level, and raise more generic exceptions to be caught at the
Container/aggregator level.

We now follow the convention that backend-level exceptions that are
specific to the implementation of that backend need to be caught and
re-raised as either built-in exceptions or MDS exceptions. Containers
and aggregators must then catch and re-raise the appropriate
interface-level exception with an appropriate interface-level message.

For the changes made in this commit, these re-raises look a bit silly
since the messages and exceptions are identical to those caught. We
leave them in, however, to indicate the clear separation between backend
and frontend, and that these exceptions/messages may differ between the
two levels.

Added seleciton tests.
@dotsdl dotsdl closed this as completed Jun 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants