Fixes #367: catch IntegrityErrors in all methods.