From 3760e5f4ef0ac0b008a5aac6b8cb754d59c34469 Mon Sep 17 00:00:00 2001 From: hjhun <36876573+hjhun@users.noreply.github.com> Date: Fri, 20 Sep 2024 21:13:03 +0900 Subject: [PATCH] [Tizen.Core] Add missing descriptions related to Exception (#6338) * [Tizen.Core] Add missing descriptions related to Exception Signed-off-by: Hwankyu Jhun * Separate try catch blocks Signed-off-by: Hwankyu Jhun --------- Signed-off-by: Hwankyu Jhun --- src/Tizen.Core/Tizen.Core/Channel.cs | 1 + src/Tizen.Core/Tizen.Core/ChannelObject.cs | 1 + src/Tizen.Core/Tizen.Core/Event.cs | 6 ++++++ src/Tizen.Core/Tizen.Core/EventObject.cs | 1 + src/Tizen.Core/Tizen.Core/Task.cs | 24 +++++++++++++++++++--- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Tizen.Core/Tizen.Core/Channel.cs b/src/Tizen.Core/Tizen.Core/Channel.cs index 402710595c5..0079e83e7e7 100644 --- a/src/Tizen.Core/Tizen.Core/Channel.cs +++ b/src/Tizen.Core/Tizen.Core/Channel.cs @@ -30,6 +30,7 @@ public class Channel : IDisposable /// Constructor for creating a new channel with a sender and a receiver. /// /// Thrown when out of memory. + /// Thrown when failed because of an invalid operation. /// /// /// diff --git a/src/Tizen.Core/Tizen.Core/ChannelObject.cs b/src/Tizen.Core/Tizen.Core/ChannelObject.cs index cc967effb7f..a721c60018b 100644 --- a/src/Tizen.Core/Tizen.Core/ChannelObject.cs +++ b/src/Tizen.Core/Tizen.Core/ChannelObject.cs @@ -39,6 +39,7 @@ public class ChannelObject : IDisposable /// The ID. /// The data object. /// Thrown when out of memory. + /// Thrown when failed because of an invalid operation. /// /// /// diff --git a/src/Tizen.Core/Tizen.Core/Event.cs b/src/Tizen.Core/Tizen.Core/Event.cs index 89c3d84af03..21755d97df4 100644 --- a/src/Tizen.Core/Tizen.Core/Event.cs +++ b/src/Tizen.Core/Tizen.Core/Event.cs @@ -34,6 +34,7 @@ public class Event : IDisposable /// Constructor for creating a new event instance. /// /// Thrown when out of memory. + /// Thrown when failed because of an invalid operation. /// /// /// @@ -98,6 +99,7 @@ private bool EventHandlerCallback(IntPtr eventData, IntPtr userData) /// /// The event object instance. /// Thrown when the argument is null. + /// Thrown when failed because of an invalid operation. /// /// If the event is not added to the task, the emitted event object will be pended until the event is added to the task. /// @@ -131,6 +133,10 @@ public void Emit(EventObject eventObject) } 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; } diff --git a/src/Tizen.Core/Tizen.Core/EventObject.cs b/src/Tizen.Core/Tizen.Core/EventObject.cs index 804a7e08a30..9012bc9094a 100644 --- a/src/Tizen.Core/Tizen.Core/EventObject.cs +++ b/src/Tizen.Core/Tizen.Core/EventObject.cs @@ -38,6 +38,7 @@ public class EventObject : IDisposable /// The ID. /// The data object. /// Thrown when out of memory. + /// Thrown when failed because of an invalid operation. /// /// /// diff --git a/src/Tizen.Core/Tizen.Core/Task.cs b/src/Tizen.Core/Tizen.Core/Task.cs index 5b05fbb1e58..40ed62cea8e 100644 --- a/src/Tizen.Core/Tizen.Core/Task.cs +++ b/src/Tizen.Core/Tizen.Core/Task.cs @@ -48,6 +48,7 @@ public class Task : IDisposable /// The ID of the task. /// Thrown when the is invalid or a Task with that ID already exists. /// Thrown when out of memory. + /// Thrown when failed because of an invalid operation. /// /// The constructor throws an exception when the id already exists. /// By default, the task creates a thread. However, if the is "main", a thread is not created. @@ -594,9 +595,26 @@ internal static Task Spawn(string id) 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; } ///