[INTERNAL] replaces some exceptions by preconditions