datajoint-python
datajoint-python copied to clipboard
Warn user if access error is encountered during table declaration
Currently the AccessError catched here is silent meaning the user has no indication it was raised in the first place. This silent error can cause other errors down the line which are harder to debug than they need to be due to the user not being aware of their root cause. Therefore I propose to display a warning to the user if an AccessError is encountered instead of just pass.
This occurs when users do not have a CREATE privilege and simply use an existing database. This is a very common scenario when the code is distributed for an existing database. In those cases, quietly skipping the failed creation is the right course of action. Perhaps one way to solve it is to provide clearer diagnostics for when the table remains underclared and the user attempts to use it.
In my case it occurred because I did not have the REFERENCES privilege for a foreign key in the table I was trying to create.
Could something like the following work?
except AccessError:
if not self.is_declared:
raise