Skip to content

Commit 00a0b32

Browse files
committed
Specific exception types
1 parent 0dee5da commit 00a0b32

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/embed_tests/TestDomainReload.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static void RunAssemblyAndUnload(Assembly assembly, string assemblyName)
212212
{
213213
Console.WriteLine($"[Program.Main] The Proxy object is valid ({theProxy}). Unexpected domain unload behavior");
214214
}
215-
catch (Exception)
215+
catch (AppDomainUnloadedException)
216216
{
217217
Console.WriteLine("[Program.Main] The Proxy object is not valid anymore, domain unload complete.");
218218
}

src/runtime/runtime_state.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static void Restore()
8282
var dummyGCAddr = PySys_GetObject("dummy_gc");
8383
if (dummyGCAddr == IntPtr.Zero)
8484
{
85-
throw new Exception("Runtime state have not set");
85+
throw new InvalidOperationException("Runtime state have not set");
8686
}
8787
var dummyGC = PyLong_AsVoidPtr(dummyGCAddr);
8888
ResotreModules(dummyGC);
@@ -122,8 +122,8 @@ private static void RestoreObjects(IntPtr dummyGC)
122122
{
123123
throw new Exception("To prevent crash by _PyObject_GC_UNTRACK in Python internal, UseDummyGC should be enabled when using ResotreObjects");
124124
}
125-
var intialObjs = PySys_GetObject("initial_objs");
126-
Debug.Assert(intialObjs != null);
125+
IntPtr intialObjs = PySys_GetObject("initial_objs");
126+
Debug.Assert(intialObjs != IntPtr.Zero);
127127
foreach (var obj in PyGCGetObjects())
128128
{
129129
var p = PyLong_FromVoidPtr(obj);
@@ -192,7 +192,7 @@ private static void ExchangeGCChain(IntPtr obj, IntPtr gc)
192192
var head = _Py_AS_GC(obj);
193193
if ((long)_PyGCHead_REFS(head) == _PyGC_REFS_UNTRACKED)
194194
{
195-
throw new Exception("GC object untracked");
195+
throw new ArgumentException("GC object untracked");
196196
}
197197
unsafe
198198
{

0 commit comments

Comments
 (0)