forked from sebastienros/fluid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExceptionHelper.cs
57 lines (49 loc) · 1.79 KB
/
ExceptionHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#nullable enable
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
namespace Fluid
{
internal static class ExceptionHelper
{
[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
public static void ThrowArgumentNullException(string paramName, string? message = null)
{
throw new ArgumentNullException(paramName, message);
}
[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
public static void ThrowInvalidOperationException(string message)
{
throw new InvalidOperationException(message);
}
[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
public static void ThrowArgumentOutOfRangeException(string paramName, string message)
{
throw new ArgumentOutOfRangeException(paramName, message);
}
[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
public static void ThrowParseException<T>(string message)
{
throw new ParseException(message);
}
[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
public static void ThrowMaximumRecursionException()
{
throw new InvalidOperationException("The maximum level of recursion has been reached. Your script must have a cyclic include statement.");
}
[DoesNotReturn]
[MethodImpl(MethodImplOptions.NoInlining)]
public static void ThrowMaximumStatementsException()
{
throw new InvalidOperationException("The maximum number of statements has been reached. Your script took too long to run.");
}
#if NETSTANDARD2_0
private class DoesNotReturnAttribute : Attribute {}
#endif
}
}