/// <summary> /// Throws an <see cref="ArgumentNullException"/>when the contract failed. /// </summary> /// <returns>An <see cref="ArgumentNullException"/> if failed, otherwise the value.</returns> /// <exception cref="ArgumentNullException">The <see cref="Predicate"/> failed.</exception> public T ThrowArgumentNullException() => IsValid ? Value : throw this.BuildException(ContractExceptionBuilders.BuildArgumentNullException <T>());
/// <summary> /// Throws the specified type of exception when the contract failed. /// </summary> /// <typeparam name="TException">Type of exception.</typeparam> /// <returns>A new exception of <typeparamref name="TException" /> type.</returns> public T ThrowException <TException>() where TException : Exception => IsValid ? Value : throw this.BuildException(ContractExceptionBuilders.BuildCustomException <T, TException>());