Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ThrowHelper.cs
Go to the documentation of this file.
4using System.IO;
7
8namespace System;
9
11internal static class ThrowHelper
12{
14 internal static void ThrowArrayTypeMismatchException()
15 {
17 }
18
24
26 internal static void ThrowIndexOutOfRangeException()
27 {
28 throw new IndexOutOfRangeException();
29 }
30
32 internal static void ThrowArgumentOutOfRangeException()
33 {
35 }
36
39 {
40 throw new ArgumentException(SR.Argument_DestinationTooShort, "destination");
41 }
42
48
51 {
52 throw GetArgumentException(ExceptionResource.Argument_CannotExtractScalar, argument);
53 }
54
57 {
59 }
60
63 {
64 throw GetArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_Index);
65 }
66
72
75 {
76 throw GetArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
77 }
78
81 {
82 throw GetArgumentOutOfRangeException(ExceptionArgument.value, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
83 }
84
87 {
88 throw GetArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum);
89 }
90
93 {
94 throw GetArgumentOutOfRangeException(ExceptionArgument.startIndex, ExceptionResource.ArgumentOutOfRange_Index);
95 }
96
99 {
100 throw GetArgumentOutOfRangeException(ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_Count);
101 }
102
104 internal static void ThrowArgumentOutOfRange_Year()
105 {
106 throw GetArgumentOutOfRangeException(ExceptionArgument.year, ExceptionResource.ArgumentOutOfRange_Year);
107 }
108
110 internal static void ThrowArgumentOutOfRange_Month(int month)
111 {
113 }
114
117 {
119 }
120
126
132
138
144
150
155
161
163 internal static void ThrowKeyNotFoundException<T>(T key)
164 {
166 }
167
173
179
182 {
184 }
185
188 {
190 }
191
197
203
209
215
221
223 internal static void ThrowEndOfFileException()
224 {
226 }
227
229 {
231 }
232
234 internal static void ThrowInvalidOperationException()
235 {
236 throw new InvalidOperationException();
237 }
238
244
250
256
259 {
261 }
262
268
274
280
286
292
295 {
297 }
298
304
306 internal static void ThrowNotSupportedException()
307 {
308 throw new NotSupportedException();
309 }
310
313 {
315 }
316
318 internal static void ThrowOutOfMemoryException()
319 {
320 throw new OutOfMemoryException();
321 }
322
328
331 {
333 }
334
340
346
352
358
364
370
376
382
388
394
400
403 {
404 throw new ArgumentOutOfRangeException("precision", SR.Format(SR.Argument_PrecisionTooLarge, (byte)99));
405 }
406
412
418
421 {
423 }
424
426 {
427 if (array == null)
428 {
429 return new ArgumentNullException("array");
430 }
431 if (offset < 0)
432 {
434 }
435 if (count < 0)
436 {
438 }
440 }
441
446
451
456
461
466
471
476
481
486
487 [MethodImpl(MethodImplOptions.AggressiveInlining)]
489 {
490 if (default(T) != null && value == null)
491 {
493 }
494 }
495
496 [MethodImpl(MethodImplOptions.AggressiveInlining)]
498 {
499 if (typeof(T) != typeof(byte) && typeof(T) != typeof(sbyte) && typeof(T) != typeof(short) && typeof(T) != typeof(ushort) && typeof(T) != typeof(int) && typeof(T) != typeof(uint) && typeof(T) != typeof(long) && typeof(T) != typeof(ulong) && typeof(T) != typeof(float) && typeof(T) != typeof(double) && typeof(T) != typeof(IntPtr) && typeof(T) != typeof(UIntPtr))
500 {
501 ThrowNotSupportedException(ExceptionResource.Arg_TypeNotSupported);
502 }
503 }
504
505 [MethodImpl(MethodImplOptions.AggressiveInlining)]
507 {
508 if (typeof(T) != typeof(byte) && typeof(T) != typeof(sbyte) && typeof(T) != typeof(short) && typeof(T) != typeof(ushort) && typeof(T) != typeof(int) && typeof(T) != typeof(uint) && typeof(T) != typeof(long) && typeof(T) != typeof(ulong) && typeof(T) != typeof(float) && typeof(T) != typeof(double))
509 {
510 ThrowNotSupportedException(ExceptionResource.Arg_TypeNotSupported);
511 }
512 }
513
515 {
516 return argument switch
517 {
518 ExceptionArgument.obj => "obj",
519 ExceptionArgument.dictionary => "dictionary",
520 ExceptionArgument.array => "array",
521 ExceptionArgument.info => "info",
522 ExceptionArgument.key => "key",
523 ExceptionArgument.text => "text",
524 ExceptionArgument.values => "values",
525 ExceptionArgument.value => "value",
526 ExceptionArgument.startIndex => "startIndex",
527 ExceptionArgument.task => "task",
528 ExceptionArgument.bytes => "bytes",
529 ExceptionArgument.byteIndex => "byteIndex",
530 ExceptionArgument.byteCount => "byteCount",
531 ExceptionArgument.ch => "ch",
532 ExceptionArgument.chars => "chars",
533 ExceptionArgument.charIndex => "charIndex",
534 ExceptionArgument.charCount => "charCount",
535 ExceptionArgument.s => "s",
536 ExceptionArgument.input => "input",
537 ExceptionArgument.ownedMemory => "ownedMemory",
538 ExceptionArgument.list => "list",
539 ExceptionArgument.index => "index",
540 ExceptionArgument.capacity => "capacity",
541 ExceptionArgument.collection => "collection",
542 ExceptionArgument.item => "item",
543 ExceptionArgument.converter => "converter",
544 ExceptionArgument.match => "match",
545 ExceptionArgument.count => "count",
546 ExceptionArgument.action => "action",
547 ExceptionArgument.comparison => "comparison",
548 ExceptionArgument.exceptions => "exceptions",
549 ExceptionArgument.exception => "exception",
550 ExceptionArgument.pointer => "pointer",
551 ExceptionArgument.start => "start",
552 ExceptionArgument.format => "format",
553 ExceptionArgument.formats => "formats",
554 ExceptionArgument.culture => "culture",
555 ExceptionArgument.comparer => "comparer",
556 ExceptionArgument.comparable => "comparable",
557 ExceptionArgument.source => "source",
558 ExceptionArgument.state => "state",
559 ExceptionArgument.length => "length",
560 ExceptionArgument.comparisonType => "comparisonType",
561 ExceptionArgument.manager => "manager",
562 ExceptionArgument.sourceBytesToCopy => "sourceBytesToCopy",
563 ExceptionArgument.callBack => "callBack",
564 ExceptionArgument.creationOptions => "creationOptions",
565 ExceptionArgument.function => "function",
566 ExceptionArgument.scheduler => "scheduler",
567 ExceptionArgument.continuationAction => "continuationAction",
568 ExceptionArgument.continuationFunction => "continuationFunction",
569 ExceptionArgument.tasks => "tasks",
570 ExceptionArgument.asyncResult => "asyncResult",
571 ExceptionArgument.beginMethod => "beginMethod",
572 ExceptionArgument.endMethod => "endMethod",
573 ExceptionArgument.endFunction => "endFunction",
574 ExceptionArgument.cancellationToken => "cancellationToken",
575 ExceptionArgument.continuationOptions => "continuationOptions",
576 ExceptionArgument.delay => "delay",
577 ExceptionArgument.millisecondsDelay => "millisecondsDelay",
578 ExceptionArgument.millisecondsTimeout => "millisecondsTimeout",
579 ExceptionArgument.stateMachine => "stateMachine",
580 ExceptionArgument.timeout => "timeout",
581 ExceptionArgument.type => "type",
582 ExceptionArgument.sourceIndex => "sourceIndex",
583 ExceptionArgument.sourceArray => "sourceArray",
584 ExceptionArgument.destinationIndex => "destinationIndex",
585 ExceptionArgument.destinationArray => "destinationArray",
586 ExceptionArgument.pHandle => "pHandle",
587 ExceptionArgument.handle => "handle",
588 ExceptionArgument.other => "other",
589 ExceptionArgument.newSize => "newSize",
590 ExceptionArgument.lowerBounds => "lowerBounds",
591 ExceptionArgument.lengths => "lengths",
592 ExceptionArgument.len => "len",
593 ExceptionArgument.keys => "keys",
594 ExceptionArgument.indices => "indices",
595 ExceptionArgument.index1 => "index1",
596 ExceptionArgument.index2 => "index2",
597 ExceptionArgument.index3 => "index3",
598 ExceptionArgument.length1 => "length1",
599 ExceptionArgument.length2 => "length2",
600 ExceptionArgument.length3 => "length3",
601 ExceptionArgument.endIndex => "endIndex",
602 ExceptionArgument.elementType => "elementType",
603 ExceptionArgument.arrayIndex => "arrayIndex",
604 ExceptionArgument.year => "year",
605 ExceptionArgument.codePoint => "codePoint",
606 ExceptionArgument.str => "str",
607 ExceptionArgument.options => "options",
608 ExceptionArgument.prefix => "prefix",
609 ExceptionArgument.suffix => "suffix",
610 ExceptionArgument.buffer => "buffer",
611 ExceptionArgument.buffers => "buffers",
612 ExceptionArgument.offset => "offset",
613 ExceptionArgument.stream => "stream",
614 _ => "",
615 };
616 }
617
619 {
620 return resource switch
621 {
691 _ => "",
692 };
693 }
694}
static string ArgumentOutOfRange_Month
Definition SR.cs:1058
static string ArgumentOutOfRange_Index
Definition SR.cs:30
static string Arg_BogusIComparer
Definition SR.cs:86
static string ObjectDisposed_StreamClosed
Definition SR.cs:20
static string InvalidOperation_ConcurrentOperationsNotSupported
Definition SR.cs:1430
static string Arg_Need3DArray
Definition SR.cs:328
static string Task_ContinueWith_NotOnAnything
Definition SR.cs:1926
static string CancellationTokenSource_Disposed
Definition SR.cs:1178
static string ArgumentOutOfRange_BadYearMonthDay
Definition SR.cs:974
static string InvalidOperation_EnumNotStarted
Definition SR.cs:46
static string ArgumentOutOfRange_SmallCapacity
Definition SR.cs:34
static string ArgumentNull_SafeHandle
Definition SR.cs:956
static string NotSupported_ReadOnlyCollection
Definition SR.cs:28
static string Arg_MustBeType
Definition SR.cs:302
static string Argument_DestinationTooShort
Definition SR.cs:14
static string InvalidOperation_WrongAsyncResultOrEndCalledMultiple
Definition SR.cs:1532
static string Task_MultiTaskContinuation_EmptyTaskList
Definition SR.cs:1938
static string Argument_SpansMustHaveSameLength
Definition SR.cs:2134
static string Argument_AddingDuplicateWithKey
Definition SR.cs:460
static string Arg_TypeNotSupported
Definition SR.cs:2066
static string Arg_LowerBoundsMustMatch
Definition SR.cs:234
static string ConcurrentCollection_SyncRoot_NotSupported
Definition SR.cs:58
static string ArgumentOutOfRange_IndexCount
Definition SR.cs:80
static string IO_EOF_ReadBeyondEOF
Definition SR.cs:56
static string Task_RunSynchronously_TaskCompleted
Definition SR.cs:1950
static string ArgumentOutOfRange_Count
Definition SR.cs:986
static string Argument_PrecisionTooLarge
Definition SR.cs:2096
static string Task_ThrowIfDisposed
Definition SR.cs:1960
static string Serialization_MissingKeys
Definition SR.cs:1892
static string ArgumentOutOfRange_GetCharCountOverflow
Definition SR.cs:90
static string Arg_WrongType
Definition SR.cs:16
static string InvalidOperation_EnumEnded
Definition SR.cs:42
static string InvalidOperation_HandleIsNotPinned
Definition SR.cs:1456
static string ArgumentException_OtherNotArrayOfCorrectLength
Definition SR.cs:918
static string Task_Start_Promise
Definition SR.cs:1956
static string TaskCompletionSourceT_TrySetException_NoExceptions
Definition SR.cs:1966
static string InvalidOperation_NullArray
Definition SR.cs:1492
static string Arg_InvalidHandle
Definition SR.cs:14
static string ArgumentOutOfRange_Enum
Definition SR.cs:18
static string InvalidOperation_IComparerFailed
Definition SR.cs:1460
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string Overflow_TimeSpanTooLong
Definition SR.cs:1784
static string Argument_InvalidFlag
Definition SR.cs:688
static string Task_WaitMulti_NullTask
Definition SR.cs:1962
static string Task_RunSynchronously_Continuation
Definition SR.cs:1946
static string Arg_Need1DArray
Definition SR.cs:324
static string Argument_AlignmentMustBePow2
Definition SR.cs:466
static string NotSupported_UnseekableStream
Definition SR.cs:26
static string Task_RunSynchronously_AlreadyStarted
Definition SR.cs:1944
static string Arg_ArrayPlusOffTooSmall
Definition SR.cs:16
static string Argument_AddingDuplicate
Definition SR.cs:14
static string Argument_InvalidArrayType
Definition SR.cs:54
static string InvalidOperation_NoValue
Definition SR.cs:1490
static string ArgumentOutOfRange_IndexCountBuffer
Definition SR.cs:78
static string NotSupported_UnwritableStream
Definition SR.cs:30
static string Task_Start_ContinuationTask
Definition SR.cs:1954
static string ArgumentNull_Array
Definition SR.cs:24
static string Argument_BadFormatSpecifier
Definition SR.cs:488
static string Arg_NonZeroLowerBound
Definition SR.cs:14
static string AsyncMethodBuilder_InstanceNotInitialized
Definition SR.cs:1146
static string Task_Start_TaskCompleted
Definition SR.cs:1958
static string ArgumentOutOfRange_BiggerThanCollection
Definition SR.cs:56
static string InvalidOperation_EnumFailedVersion
Definition SR.cs:44
static string Arg_RanksAndBounds
Definition SR.cs:384
static string Argument_CannotExtractScalar
Definition SR.cs:2090
static string Argument_OverlapAlignmentMismatch
Definition SR.cs:2076
static string InvalidOperation_HandleIsNotInitialized
Definition SR.cs:1454
static string Arg_RankMultiDimNotSupported
Definition SR.cs:18
static string NotSupported_FixedSizeCollection
Definition SR.cs:1674
static string Argument_InvalidArgumentForComparison
Definition SR.cs:640
static string ArgumentOutOfRange_Year
Definition SR.cs:1128
static string NotSupported_ValueCollectionSet
Definition SR.cs:42
static string Task_InvalidTimerTimeSpan
Definition SR.cs:1928
static string ArgumentOutOfRange_ListInsert
Definition SR.cs:1056
static string NotSupported_UnreadableStream
Definition SR.cs:32
static string ArgumentException_ValueTupleIncorrectType
Definition SR.cs:926
static string ArgumentOutOfRange_BadHourMinuteSecond
Definition SR.cs:972
static string Serialization_NullKey
Definition SR.cs:1900
static string Task_MultiTaskContinuation_NullTask
Definition SR.cs:1942
static string ArgumentOutOfRange_HugeArrayNotSupported
Definition SR.cs:1026
static string Task_Start_AlreadyStarted
Definition SR.cs:1952
static string Arg_Need2DArray
Definition SR.cs:326
static string Rank_MultiDimNotSupported
Definition SR.cs:1826
static string Argument_InvalidOffLen
Definition SR.cs:22
static string TaskCompletionSourceT_TrySetException_NullException
Definition SR.cs:1968
static string InvalidOperation_EnumOpCantHappen
Definition SR.cs:48
static string Task_Delay_InvalidMillisecondsDelay
Definition SR.cs:1930
static string Argument_InvalidTypeWithPointersNotSupported
Definition SR.cs:752
static string TaskT_TransitionToFinal_AlreadyCompleted
Definition SR.cs:1984
static string Task_ContinueWith_ESandLR
Definition SR.cs:1924
static string ArgumentOutOfRange_DayNumber
Definition SR.cs:1060
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
static string Arg_NeedAtLeast1Rank
Definition SR.cs:330
static string Arg_RankIndices
Definition SR.cs:380
static string Arg_HandleNotAsync
Definition SR.cs:180
static string Arg_KeyNotFoundWithKey
Definition SR.cs:94
static string Task_RunSynchronously_Promise
Definition SR.cs:1948
static string ObjectDisposed_FileClosed
Definition SR.cs:28
static string Arg_HandleNotSync
Definition SR.cs:182
static string ArgumentOutOfRange_EndIndexStartIndex
Definition SR.cs:1008
static string Task_Dispose_NotCompleted
Definition SR.cs:1932
static string NotSupported_KeyCollectionSet
Definition SR.cs:50
static string NotSupported_StringComparison
Definition SR.cs:1712
Definition SR.cs:7
static void ThrowInvalidOperationException_EnumCurrent(int index)
static void ThrowArgumentException_CannotExtractScalar(ExceptionArgument argument)
static string GetResourceString(ExceptionResource resource)
static void ThrowInvalidOperationException(ExceptionResource resource, Exception e)
static ArgumentException GetArgumentException(ExceptionResource resource)
static void ThrowArgumentOutOfRangeException_PrecisionTooLarge()
static void ThrowNotSupportedException_UnwritableStream()
static void ThrowArgumentOutOfRange_Month(int month)
static void ThrowArgumentNullException(ExceptionArgument argument)
static void ThrowNotSupportedException(ExceptionResource resource)
static void ThrowCountArgumentOutOfRange_ArgumentOutOfRange_Count()
static Exception GetArraySegmentCtorValidationFailedException(Array array, int offset, int count)
static void ArgumentOutOfRangeException_Enum_Value()
static void ThrowFormatException_BadFormatSpecifier()
static void ThrowValueArgumentOutOfRange_NeedNonNegNumException()
static void ThrowArrayTypeMismatchException()
static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument, int paramNumber, ExceptionResource resource)
static void ThrowWrongValueTypeArgumentException< T >(T value, Type targetType)
static void ThrowInvalidOperationException(ExceptionResource resource)
static void ThrowIndexOutOfRangeException()
static void ThrowArgumentOutOfRangeException()
static ArgumentException GetAddingDuplicateWithKeyArgumentException(object key)
static ArgumentException GetWrongValueTypeArgumentException(object value, Type targetType)
static void ThrowArraySegmentCtorValidationFailedExceptions(Array array, int offset, int count)
static void ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen()
static void ThrowArgumentException_InvalidHandle(string paramName)
static void ThrowArgumentOutOfRange_IndexException()
static void ThrowArgumentException_BadComparer(object comparer)
static void ThrowLengthArgumentOutOfRange_ArgumentOutOfRange_NeedNonNegNum()
static void ThrowArgumentOutOfRangeException_NeedNonNegNum(string paramName)
static string GetArgumentName(ExceptionArgument argument)
static void ThrowInvalidOperationException_HandleIsNotInitialized()
static void ThrowOutOfMemoryException()
static void ThrowWrongKeyTypeArgumentException< T >(T key, Type targetType)
static ArgumentOutOfRangeException GetArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
static void ThrowObjectDisposedException(ExceptionResource resource)
static void ThrowInvalidOperationException()
static InvalidOperationException GetInvalidOperationException(ExceptionResource resource)
static void ThrowArgumentOutOfRange_Year()
static void ThrowArgumentOutOfRangeException(ExceptionArgument argument)
static ArgumentException GetWrongKeyTypeArgumentException(object key, Type targetType)
static void ThrowArgumentException_Argument_InvalidArrayType()
static void ThrowAggregateException(List< Exception > exceptions)
static void ThrowArgumentException_HandleNotSync(string paramName)
static void ThrowForUnsupportedIntrinsicsVectorBaseType< T >()
static void ThrowInvalidTypeWithPointersNotSupported(Type targetType)
static void ThrowNotSupportedException_UnseekableStream()
static KeyNotFoundException GetKeyNotFoundException(object key)
static void ThrowArgumentOutOfRangeException_SymbolDoesNotFit()
static void ThrowArgumentException_TupleIncorrectType(object obj)
static void ThrowNotSupportedException()
static void ThrowInvalidOperationException_InvalidOperation_NoValue()
static void ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_Index()
static void ThrowArgumentNullException(string name)
static void ThrowInvalidOperationException_HandleIsNotPinned()
static void ThrowAddingDuplicateWithKeyArgumentException< T >(T key)
static void ThrowArgumentOutOfRange_BadYearMonthDay()
static void ThrowArgumentOutOfRange_TimeSpanTooLong()
static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, int paramNumber, ExceptionResource resource)
static void ThrowArgumentNullException(ExceptionArgument argument, ExceptionResource resource)
static void ThrowForUnsupportedNumericsVectorBaseType< T >()
static void ThrowArgumentException_HandleNotAsync(string paramName)
static void ThrowArgumentOutOfRange_DayNumber(int dayNumber)
static void ThrowObjectDisposedException_FileClosed()
static void ThrowSerializationException(ExceptionResource resource)
static void ThrowArgumentException(ExceptionResource resource)
static void ThrowArgumentOutOfRange_BadHourMinuteSecond()
static void ThrowEndOfFileException()
static void ThrowInvalidOperationException_InvalidOperation_EnumFailedVersion()
static Exception CreateEndOfFileException()
static void ThrowArgumentException(ExceptionResource resource, ExceptionArgument argument)
static void ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
static ArgumentException GetArgumentException(ExceptionResource resource, ExceptionArgument argument)
static void ThrowArgumentException_OverlapAlignmentMismatch()
static void ThrowIndexArgumentOutOfRange_NeedNonNegNumException()
static void ThrowArgumentException_DestinationTooShort()
static void ThrowObjectDisposedException_StreamClosed(string objectName)
static void ThrowRankException(ExceptionResource resource)
static void ThrowInvalidOperationException_InvalidOperation_EnumEnded()
static void ThrowInvalidOperationException_ConcurrentOperationsNotSupported()
static void ThrowNotSupportedException_UnreadableStream()
static InvalidOperationException GetInvalidOperationException_EnumCurrent(int index)
static void ThrowInvalidOperationException_InvalidOperation_EnumNotStarted()
static void IfNullAndNullsAreIllegalThenThrow< T >(object value, ExceptionArgument argName)
static void ThrowKeyNotFoundException< T >(T key)