Skip to content

Commit 8f106a7

Browse files
authored
Rename ExceptionHelper to Throw and shorter method names (#2148)
1 parent cb2474c commit 8f106a7

File tree

170 files changed

+735
-735
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+735
-735
lines changed

Jint.Tests.Test262/Test262ModuleLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected override string LoadModuleContents(Engine engine, ResolvedSpecifier re
2929
var fileName = Path.Combine(_basePath, resolved.Key).Replace('\\', '/');
3030
if (!_fileSystem.FileExists(fileName))
3131
{
32-
ExceptionHelper.ThrowModuleResolutionException("Module Not Found", resolved.ModuleRequest.Specifier, parent: null, fileName);
32+
Throw.ModuleResolutionException("Module Not Found", resolved.ModuleRequest.Specifier, parent: null, fileName);
3333
}
3434
using var stream = new StreamReader(_fileSystem.OpenFile(fileName, FileMode.Open, FileAccess.Read));
3535
return stream.ReadToEnd();

Jint/AstExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static JsValue GetKey(this Expression expression, Engine engine, bool res
2727
return TypeConverter.ToPropertyKey(key);
2828
}
2929

30-
ExceptionHelper.ThrowArgumentException("Unable to extract correct key, node type: " + expression.Type);
30+
Throw.ArgumentException("Unable to extract correct key, node type: " + expression.Type);
3131
return JsValue.Undefined;
3232
}
3333

@@ -324,7 +324,7 @@ internal static Record DefineMethod<T>(this T m, ObjectInstance obj, ObjectInsta
324324
var function = m.Value as IFunction;
325325
if (function is null)
326326
{
327-
ExceptionHelper.ThrowSyntaxError(engine.Realm);
327+
Throw.SyntaxError(engine.Realm);
328328
}
329329

330330
var definition = new JintFunctionDefinition(function);
@@ -552,7 +552,7 @@ protected override object VisitClassBody(ClassBody classBody)
552552
[MethodImpl(MethodImplOptions.NoInlining)]
553553
private static void Throw(Realm r, PrivateIdentifier id)
554554
{
555-
ExceptionHelper.ThrowSyntaxError(r, $"Private field '#{id.Name}' must be declared in an enclosing class");
555+
Runtime.Throw.SyntaxError(r, $"Private field '#{id.Name}' must be declared in an enclosing class");
556556
}
557557
}
558558
}

Jint/Collections/ListDictionary.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public bool Add(Key key, TValue value, bool tryAdd = false)
8585
{
8686
return false;
8787
}
88-
ExceptionHelper.ThrowArgumentException();
88+
Throw.ArgumentException();
8989
}
9090

9191
last = node;

Jint/Collections/ObjectTraverseStack.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public bool TryEnter(JsValue value)
2020
{
2121
if (value is null)
2222
{
23-
ExceptionHelper.ThrowArgumentNullException(nameof(value));
23+
Throw.ArgumentNullException(nameof(value));
2424
}
2525

2626
if (_stack.Contains(value))
@@ -37,7 +37,7 @@ public void Enter(JsValue value)
3737
{
3838
if (!TryEnter(value))
3939
{
40-
ExceptionHelper.ThrowTypeError(_engine.Realm, "Cyclic reference detected.");
40+
Throw.TypeError(_engine.Realm, "Cyclic reference detected.");
4141
}
4242
}
4343

Jint/Collections/RefStack.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public ref readonly T Pop()
5454
{
5555
if (_size == 0)
5656
{
57-
ExceptionHelper.ThrowInvalidOperationException("stack is empty");
57+
Throw.InvalidOperationException("stack is empty");
5858
}
5959

6060
_size--;

Jint/Constraints/CancellationConstraint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public override void Check()
1616
{
1717
if (_cancellationToken.IsCancellationRequested)
1818
{
19-
ExceptionHelper.ThrowExecutionCanceledException();
19+
Throw.ExecutionCanceledException();
2020
}
2121
}
2222

Jint/Constraints/MaxStatementsConstraint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public override void Check()
2020
{
2121
if (MaxStatements > 0 && ++_statementsCount > MaxStatements)
2222
{
23-
ExceptionHelper.ThrowStatementsCountOverflowException();
23+
Throw.StatementsCountOverflowException();
2424
}
2525
}
2626

Jint/Constraints/MemoryLimitConstraint.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ public override void Check()
3838
#else
3939
if (_getAllocatedBytesForCurrentThread == null)
4040
{
41-
ExceptionHelper.ThrowPlatformNotSupportedException("The current platform doesn't support MemoryLimit.");
41+
Throw.PlatformNotSupportedException("The current platform doesn't support MemoryLimit.");
4242
}
4343

4444
var usage = _getAllocatedBytesForCurrentThread();
4545
#endif
4646
if (usage - _initialMemoryUsage > _memoryLimit)
4747
{
48-
ExceptionHelper.ThrowMemoryLimitExceededException($"Script has allocated {usage - _initialMemoryUsage} but is limited to {_memoryLimit}");
48+
Throw.MemoryLimitExceededException($"Script has allocated {usage - _initialMemoryUsage} but is limited to {_memoryLimit}");
4949
}
5050
}
5151

Jint/Constraints/TimeConstraint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public override void Check()
1919
{
2020
if (_cts?.IsCancellationRequested == true)
2121
{
22-
ExceptionHelper.ThrowTimeoutException();
22+
Throw.TimeoutException();
2323
}
2424
}
2525

Jint/Engine.Modules.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ internal ObjectInstance Import(ModuleRequest request, string? referencingModuleL
131131

132132
if (cyclicModule.Status != ModuleStatus.Evaluated)
133133
{
134-
ExceptionHelper.ThrowNotSupportedException($"Error while evaluating module: Module is in an invalid state: '{cyclicModule.Status}'");
134+
Throw.NotSupportedException($"Error while evaluating module: Module is in an invalid state: '{cyclicModule.Status}'");
135135
}
136136
}
137137

@@ -165,7 +165,7 @@ private JsValue EvaluateModule(string specifier, Module module)
165165
// This should instead be returned and resolved in ImportModule(specifier) only so Host.ImportModuleDynamically can use this promise
166166
if (evaluationResult is not JsPromise promise)
167167
{
168-
ExceptionHelper.ThrowInvalidOperationException($"Error while evaluating module: Module evaluation did not return a promise: {evaluationResult.Type}");
168+
Throw.InvalidOperationException($"Error while evaluating module: Module evaluation did not return a promise: {evaluationResult.Type}");
169169
}
170170
else if (promise.State == PromiseState.Rejected)
171171
{
@@ -174,11 +174,11 @@ private JsValue EvaluateModule(string specifier, Module module)
174174
: SourceLocation.From(new Position(), new Position());
175175

176176
var node = AstExtensions.CreateLocationNode(location);
177-
ExceptionHelper.ThrowJavaScriptException(_engine, promise.Value, node.Location);
177+
Throw.JavaScriptException(_engine, promise.Value, node.Location);
178178
}
179179
else if (promise.State != PromiseState.Fulfilled)
180180
{
181-
ExceptionHelper.ThrowInvalidOperationException($"Error while evaluating module: Module evaluation did not return a fulfilled promise: {promise.State}");
181+
Throw.InvalidOperationException($"Error while evaluating module: Module evaluation did not return a fulfilled promise: {promise.State}");
182182
}
183183

184184
return evaluationResult;

0 commit comments

Comments
 (0)