Skip to content

Commit

Permalink
[Tizen.Core] Add missing descriptions related to Exception (Samsung#6338
Browse files Browse the repository at this point in the history
)

* [Tizen.Core] Add missing descriptions related to Exception

Signed-off-by: Hwankyu Jhun <[email protected]>

* Separate try catch blocks

Signed-off-by: Hwankyu Jhun <[email protected]>

---------

Signed-off-by: Hwankyu Jhun <[email protected]>
  • Loading branch information
hjhun authored Sep 20, 2024
1 parent 6b2f6cd commit 3760e5f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/Tizen.Core/Tizen.Core/Channel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class Channel : IDisposable
/// 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>
///
Expand Down
1 change: 1 addition & 0 deletions src/Tizen.Core/Tizen.Core/ChannelObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ChannelObject : IDisposable
/// <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>
///
Expand Down
6 changes: 6 additions & 0 deletions src/Tizen.Core/Tizen.Core/Event.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class Event : IDisposable
/// 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>
///
Expand Down Expand Up @@ -98,6 +99,7 @@ private bool EventHandlerCallback(IntPtr eventData, IntPtr userData)
/// </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>
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/Tizen.Core/Tizen.Core/EventObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class EventObject : IDisposable
/// <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>
///
Expand Down
24 changes: 21 additions & 3 deletions src/Tizen.Core/Tizen.Core/Task.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class Task : IDisposable
/// <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.
Expand Down Expand Up @@ -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;
}

/// <summary>
Expand Down

0 comments on commit 3760e5f

Please sign in to comment.