Add some exceptions for API of SendLaunchRequest 06/151106/5
authorJunghoon Park <jh9216.park@samsung.com>
Wed, 20 Sep 2017 01:38:40 +0000 (10:38 +0900)
committerJunghoon Park <jh9216.park@samsung.com>
Thu, 21 Sep 2017 08:35:55 +0000 (08:35 +0000)
- New exceptions are added; AppNotFoundException, LaunchFailedException,
  LaunchRejectedException, OutOfMemoryException and
PermissionDeniedException

Change-Id: I959eb7f317438d07290e482b24cd2cf9ac18e9a8
Signed-off-by: Junghoon Park <jh9216.park@samsung.com>
src/Tizen.Applications.Common/Tizen.Applications.Exceptions/AppNotFoundException.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchFailedException.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchRejectedException.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.Exceptions/OutOfMemoryException.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications.Exceptions/PermissionDeniedException.cs [new file with mode: 0755]
src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs

diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/AppNotFoundException.cs b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/AppNotFoundException.cs
new file mode 100755 (executable)
index 0000000..6c9454d
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+
+namespace Tizen.Applications.Exceptions
+{
+    /// <summary>
+    /// The class that represents the exception which will be thrown when the application to run is not found
+    /// </summary>
+    public class AppNotFoundException : InvalidOperationException
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="message">The localized error message string</param>
+        public AppNotFoundException(string message) : base(message)
+        {
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchFailedException.cs b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchFailedException.cs
new file mode 100755 (executable)
index 0000000..99085f7
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+
+namespace Tizen.Applications.Exceptions
+{
+    /// <summary>
+    /// The class that represents the exception which will be thrown when the request failed to launch the application
+    /// </summary>
+    public class LaunchFailedException : InvalidOperationException
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="message">The localized error message string</param>
+        public LaunchFailedException(string message) : base(message)
+        {
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchRejectedException.cs b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchRejectedException.cs
new file mode 100755 (executable)
index 0000000..e89de76
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+
+namespace Tizen.Applications.Exceptions
+{
+    /// <summary>
+    /// The class that represents the exception which will be thrown when the launch request is rejected
+    /// </summary>
+    public class LaunchRejectedException : InvalidOperationException
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="message">The localized error message string</param>
+        public LaunchRejectedException(string message) : base(message)
+        {
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/OutOfMemoryException.cs b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/OutOfMemoryException.cs
new file mode 100755 (executable)
index 0000000..f6c5967
--- /dev/null
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.Exceptions
+{
+    /// <summary>
+    /// The class that represents the exception which will be thrown when the memory is insufficient
+    /// </summary>
+    public class OutOfMemoryException : InvalidOperationException
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="message">The localized error message string</param>
+        public OutOfMemoryException(string message) : base(message)
+        {
+        }
+    }
+}
diff --git a/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/PermissionDeniedException.cs b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/PermissionDeniedException.cs
new file mode 100755 (executable)
index 0000000..015ae13
--- /dev/null
@@ -0,0 +1,18 @@
+using System;
+
+namespace Tizen.Applications.Exceptions
+{
+    /// <summary>
+    /// The class that represents the exception which will be thrown when the permission is denied
+    /// </summary>
+    public class PermissionDeniedException : InvalidOperationException
+    {
+        /// <summary>
+        /// Constructor
+        /// </summary>
+        /// <param name="message">The localized error message string</param>
+        public PermissionDeniedException(string message) : base(message)
+        {
+        }
+    }
+}
index fd4c79c..a0e1f88 100755 (executable)
@@ -501,7 +501,11 @@ namespace Tizen.Applications
         /// <param name="launchRequest">The AppControl.</param>
         /// <param name="replyAfterLaunching">The callback function to be called when the reply is delivered.</param>
         /// <exception cref="ArgumentException">Thrown when failed because of the argument is invalid.</exception>
-        /// <exception cref="InvalidOperationException">Thrown when failed because of an invalid operation.</exception>
+        /// <exception cref="Exceptions.AppNotFoundException">Thrown when the application to run is not found.</exception>
+        /// <exception cref="Exceptions.LaunchFailedException">Thrown when the request failed to launch the application.</exception>
+        /// <exception cref="Exceptions.LaunchRejectedException">Thrown when the launch request is rejected.</exception>
+        /// <exception cref="Exceptions.OutOfMemoryException">Thrown when the memory is insufficient.</exception>
+        /// <exception cref="Exceptions.PermissionDeniedException">Thrown when the permission is denied.</exception>
         /// <exception cref="TimeoutException">Thrown when failed because of timeout.</exception>
         /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
         /// <example>
@@ -559,8 +563,19 @@ namespace Tizen.Applications
                         throw new ArgumentException("Invalid Arguments");
                     case Interop.AppControl.ErrorCode.TimedOut:
                         throw new TimeoutException("Timed out");
+                    case Interop.AppControl.ErrorCode.OutOfMemory:
+                        throw new Exceptions.OutOfMemoryException("Out-of-memory");
+                    case Interop.AppControl.ErrorCode.AppNotFound:
+                        throw new Exceptions.AppNotFoundException("App not found");
+                    case Interop.AppControl.ErrorCode.LaunchRejected:
+                        throw new Exceptions.LaunchRejectedException("Launch rejected");
+                    case Interop.AppControl.ErrorCode.LaunchFailed:
+                        throw new Exceptions.LaunchFailedException("Launch failed");
+                    case Interop.AppControl.ErrorCode.PermissionDenied:
+                        throw new Exceptions.PermissionDeniedException("Permission denied");
+
                     default:
-                        throw new InvalidOperationException("Error = " + err);
+                        throw new Exceptions.LaunchRejectedException("Launch rejected");
                 }
             }
         }