[Tizen.Core] Add missing descriptions related to Exception (#6338)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Fri, 20 Sep 2024 12:13:03 +0000 (21:13 +0900)
committerGitHub <noreply@github.com>
Fri, 20 Sep 2024 12:13:03 +0000 (21:13 +0900)
* [Tizen.Core] Add missing descriptions related to Exception

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
* Separate try catch blocks

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
---------

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.Core/Tizen.Core/Channel.cs
src/Tizen.Core/Tizen.Core/ChannelObject.cs
src/Tizen.Core/Tizen.Core/Event.cs
src/Tizen.Core/Tizen.Core/EventObject.cs
src/Tizen.Core/Tizen.Core/Task.cs

index 402710595c59cc649e5bd0a990c7116cde3faceb..0079e83e7e7c427a48ecc861c9c0b488665c719e 100644 (file)
@@ -30,6 +30,7 @@ namespace Tizen.Core
         /// Constructor for creating a new channel with a sender and a receiver.
         /// </summary>
         /// <exception cref="OutOfMemoryException">Thrown when out of memory.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of an invalid operation.</exception>
         /// <example>
         /// <code>
         /// 
index cc967effb7f9b74c73b59a274b70db70c6614256..a721c60018bf274e255cd2cfa6705a8da9cec11f 100644 (file)
@@ -39,6 +39,7 @@ namespace Tizen.Core
         /// <param name="id">The ID.</param>
         /// <param name="data">The data object.</param>
         /// <exception cref="OutOfMemoryException">Thrown when out of memory.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of an invalid operation.</exception>
         /// <example>
         /// <code>
         /// 
index 89c3d84af0311ee53ffcd6b6a72ad8bd6b543cbc..21755d97df4afdcc95a9d0f68899506bb81fd362 100644 (file)
@@ -34,6 +34,7 @@ namespace Tizen.Core
         /// Constructor for creating a new event instance.
         /// </summary>
         /// <exception cref="OutOfMemoryException">Thrown when out of memory.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of an invalid operation.</exception>
         /// <example>
         /// <code>
         /// 
@@ -98,6 +99,7 @@ namespace Tizen.Core
         /// </summary>
         /// <param name="eventObject">The event object instance.</param>
         /// <exception cref="ArgumentNullException">Thrown when the argument is null.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of an invalid operation.</exception>
         /// <remarks>
         /// If the event is not added to the task, the emitted event object will be pended until the event is added to the task.
         /// </remarks>
@@ -131,6 +133,10 @@ namespace Tizen.Core
             }
 
             Interop.LibTizenCore.ErrorCode error = Interop.LibTizenCore.TizenCoreEvent.Emit(_handle, eventObject.Handle);
+            if (error == Interop.LibTizenCore.ErrorCode.InvalidParameter)
+            {
+                error = Interop.LibTizenCore.ErrorCode.InvalidContext;
+            }
             TCoreErrorFactory.CheckAndThrownException(error, "Failed to emit event object");
             eventObject.Handle = IntPtr.Zero;
         }
index 804a7e08a302f0b7be4943901217649d959d1242..9012bc9094ae0123601a1f875dfd92ad5455e61b 100644 (file)
@@ -38,6 +38,7 @@ namespace Tizen.Core
         /// <param name="id">The ID.</param>
         /// <param name="data">The data object.</param>
         /// <exception cref="OutOfMemoryException">Thrown when out of memory.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of an invalid operation.</exception>
         /// <example>
         /// <code>
         /// 
index 5b05fbb1e5841cce75ce07343a43296b5ac97bb2..40ed62cea8ee7afda96347795360bf7cac4fe30f 100644 (file)
@@ -48,6 +48,7 @@ namespace Tizen.Core
         /// <param name="id">The ID of the task.</param>
         /// <exception cref="ArgumentException">Thrown when the <paramref name="id"/> is invalid or a Task with that ID already exists.</exception>
         /// <exception cref="OutOfMemoryException">Thrown when out of memory.</exception>
+        /// <exception cref="InvalidOperationException">Thrown when failed because of an invalid operation.</exception>
         /// <remarks>
         /// The constructor throws an exception when the id already exists.
         /// By default, the task creates a thread. However, if the <paramref name="id"/> is "main", a thread is not created.
@@ -594,9 +595,26 @@ namespace Tizen.Core
                 return null;
             }
 
-            var task = new Task(id);
-            task.Run();
-            return task;
+            try
+            {
+                var task = new Task(id);
+                task.Run();
+                return task;
+            }
+            catch (ArgumentException)
+            {
+                Log.Error("ArgumentException occurs");
+            }
+            catch (OutOfMemoryException)
+            {
+                Log.Error("OutOfMemoryException occurs");
+            }
+            catch (InvalidOperationException)
+            {
+                Log.Error("InvalidOperationException occurs");
+            }
+
+            return null;
         }
 
         /// <summary>