Raise errors when necessary