Throw ArgumentException not IndexOutOfRangeException

This commit is contained in:
Oliver Booth 2022-11-30 18:17:20 +00:00
parent cfd1e4c208
commit e4f692d599
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
1 changed files with 2 additions and 2 deletions

View File

@ -63,12 +63,12 @@ public struct Vector3d : IEquatable<Vector3d>, IFormattable
/// <see cref="ReadOnlySpan{Single}" />. The span must contain at least 3 elements. /// <see cref="ReadOnlySpan{Single}" />. The span must contain at least 3 elements.
/// </summary> /// </summary>
/// <param name="values">The span of elements to assign to the vector.</param> /// <param name="values">The span of elements to assign to the vector.</param>
/// <exception cref="IndexOutOfRangeException"><paramref name="values" /> contains fewer than 3 elements.</exception> /// <exception cref="ArgumentException"><paramref name="values" /> contains fewer than 3 elements.</exception>
public Vector3d(ReadOnlySpan<double> values) public Vector3d(ReadOnlySpan<double> values)
{ {
if (values.Length < 3) if (values.Length < 3)
{ {
throw new IndexOutOfRangeException("The specified span has an insufficient number of elements."); throw new ArgumentException("The specified span has an insufficient number of elements.", nameof(values));
} }
this = Unsafe.ReadUnaligned<Vector3d>(ref Unsafe.As<double, byte>(ref MemoryMarshal.GetReference(values))); this = Unsafe.ReadUnaligned<Vector3d>(ref Unsafe.As<double, byte>(ref MemoryMarshal.GetReference(values)));