A layer cannot be created e.g. when creating a reserved-name attributes
with the wrong domain/type.
Caused by 101d04f41f [which just did not
check if the layer creation was successful].
This should go into 3.6 LTS as well.
Pull Request: https://projects.blender.org/blender/blender/pulls/118378