Browse Source

rename: rename LuaCancelledException to LuaCanceledException for consistency

Akeit0 7 months ago
parent
commit
2b5e0a2297

+ 2 - 2
src/Lua/Exceptions.cs

@@ -255,7 +255,7 @@ public class LuaAssertionException(LuaThread? traceback, string message) : LuaRu
 
 public class LuaModuleNotFoundException(string moduleName) : Exception($"module '{moduleName}' not found");
 
-public sealed class LuaCancelledException : OperationCanceledException, ILuaTracebackBuildable
+public sealed class LuaCanceledException : OperationCanceledException, ILuaTracebackBuildable
 {
     Traceback? luaTraceback;
 
@@ -274,7 +274,7 @@ public sealed class LuaCancelledException : OperationCanceledException, ILuaTrac
 
     internal LuaThread? Thread { get; private set; }
 
-    internal LuaCancelledException(LuaThread thread, CancellationToken cancellationToken, Exception? innerException = null) : base("The operation was cancelled during execution on Lua.", innerException, cancellationToken)
+    internal LuaCanceledException(LuaThread thread, CancellationToken cancellationToken, Exception? innerException = null) : base("The operation was cancelled during execution on Lua.", innerException, cancellationToken)
     {
         thread.CurrentException?.BuildOrGet();
         thread.ExceptionTrace.Clear();

+ 1 - 1
src/Lua/LuaThreadExtensions.cs

@@ -25,7 +25,7 @@ public static class LuaThreadExtensions
 
         static void Throw(LuaThread thread, CancellationToken cancellationToken)
         {
-            throw new LuaCancelledException(thread, cancellationToken);
+            throw new LuaCanceledException(thread, cancellationToken);
         }
     }
 }

+ 3 - 3
src/Lua/Runtime/LuaVirtualMachine.cs

@@ -815,7 +815,7 @@ public static partial class LuaVirtualMachine
         catch (Exception e)
         {
             context.State.CloseUpValues(context.Thread, context.FrameBase);
-            if (e is not (LuaRuntimeException or LuaCancelledException))
+            if (e is not (LuaRuntimeException or LuaCanceledException))
             {
                 var newException = new LuaRuntimeException(context.Thread, e);
                 context.PopOnTopCallStackFrames();
@@ -1199,9 +1199,9 @@ public static partial class LuaVirtualMachine
         }
         catch(OperationCanceledException  operationCanceledException)
         {
-            if(operationCanceledException is not LuaCancelledException)
+            if(operationCanceledException is not LuaCanceledException)
             {
-                throw new LuaCancelledException(thread, cancellationToken, operationCanceledException);
+                throw new LuaCanceledException(thread, cancellationToken, operationCanceledException);
             }
             throw;
         }

+ 2 - 2
src/Lua/Standard/BasicLibrary.cs

@@ -262,10 +262,10 @@ public sealed class BasicLibrary
             context.Thread.PopCallStackFrameUntil(frameCount);
             switch (ex)
             {
-                case LuaCancelledException:
+                case LuaCanceledException:
                     throw;
                 case OperationCanceledException:
-                    throw new LuaCancelledException(context.Thread,cancellationToken, ex);
+                    throw new LuaCanceledException(context.Thread,cancellationToken, ex);
                 case LuaRuntimeException luaEx:
                     luaEx.Forget();
                     return context.Return(false, luaEx.ErrorObject);

+ 8 - 8
tests/Lua.Tests/CancellationTest.cs

@@ -65,8 +65,8 @@ public class CancellationTest
         }
         catch (Exception e)
         {
-            Assert.That(e, Is.TypeOf<LuaCancelledException>());
-            var luaCancelledException = (LuaCancelledException)e;
+            Assert.That(e, Is.TypeOf<LuaCanceledException>());
+            var luaCancelledException = (LuaCanceledException)e;
             Assert.That(luaCancelledException.InnerException, Is.TypeOf<TaskCanceledException>());
             var luaStackTrace = luaCancelledException.LuaTraceback!.ToString();
             Console.WriteLine(luaStackTrace);
@@ -94,8 +94,8 @@ public class CancellationTest
         }
         catch (Exception e)
         {
-            Assert.That(e, Is.TypeOf<LuaCancelledException>());
-            var luaCancelledException = (LuaCancelledException)e;
+            Assert.That(e, Is.TypeOf<LuaCanceledException>());
+            var luaCancelledException = (LuaCanceledException)e;
             Assert.That(luaCancelledException.InnerException, Is.Null);
             var luaStackTrace = luaCancelledException.LuaTraceback!.ToString();
             Console.WriteLine(luaStackTrace);
@@ -128,9 +128,9 @@ public class CancellationTest
         }
         catch (Exception e)
         {
-            Assert.That(e, Is.TypeOf<LuaCancelledException>());
+            Assert.That(e, Is.TypeOf<LuaCanceledException>());
             Console.WriteLine(e.StackTrace);
-            var luaCancelledException = (LuaCancelledException)e;
+            var luaCancelledException = (LuaCanceledException)e;
             Assert.That(luaCancelledException.InnerException, Is.Null);
             var traceback = luaCancelledException.LuaTraceback;
             if (traceback != null)
@@ -165,9 +165,9 @@ public class CancellationTest
         }
         catch (Exception e)
         {
-            Assert.That(e, Is.TypeOf<LuaCancelledException>());
+            Assert.That(e, Is.TypeOf<LuaCanceledException>());
             Console.WriteLine(e.StackTrace);
-            var luaCancelledException = (LuaCancelledException)e;
+            var luaCancelledException = (LuaCanceledException)e;
             Assert.That(luaCancelledException.InnerException, Is.Null);
             var traceback = luaCancelledException.LuaTraceback;
             if (traceback != null)