From 3ab9e3cd919776769beab070f2029c04ee17aa99 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Wed, 20 Sep 2017 10:38:40 +0900 Subject: [PATCH] Add some exceptions for API of SendLaunchRequest - New exceptions are added; AppNotFoundException, LaunchFailedException, LaunchRejectedException, OutOfMemoryException and PermissionDeniedException Change-Id: I959eb7f317438d07290e482b24cd2cf9ac18e9a8 Signed-off-by: Junghoon Park --- .../AppNotFoundException.cs | 18 ++++++++++++++++++ .../LaunchFailedException.cs | 18 ++++++++++++++++++ .../LaunchRejectedException.cs | 18 ++++++++++++++++++ .../OutOfMemoryException.cs | 20 ++++++++++++++++++++ .../PermissionDeniedException.cs | 18 ++++++++++++++++++ .../Tizen.Applications/AppControl.cs | 19 +++++++++++++++++-- 6 files changed, 109 insertions(+), 2 deletions(-) create mode 100755 src/Tizen.Applications.Common/Tizen.Applications.Exceptions/AppNotFoundException.cs create mode 100755 src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchFailedException.cs create mode 100755 src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchRejectedException.cs create mode 100755 src/Tizen.Applications.Common/Tizen.Applications.Exceptions/OutOfMemoryException.cs create mode 100755 src/Tizen.Applications.Common/Tizen.Applications.Exceptions/PermissionDeniedException.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 index 0000000..6c9454d --- /dev/null +++ b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/AppNotFoundException.cs @@ -0,0 +1,18 @@ +using System; + +namespace Tizen.Applications.Exceptions +{ + /// + /// The class that represents the exception which will be thrown when the application to run is not found + /// + public class AppNotFoundException : InvalidOperationException + { + /// + /// Constructor + /// + /// The localized error message string + 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 index 0000000..99085f7 --- /dev/null +++ b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchFailedException.cs @@ -0,0 +1,18 @@ +using System; + +namespace Tizen.Applications.Exceptions +{ + /// + /// The class that represents the exception which will be thrown when the request failed to launch the application + /// + public class LaunchFailedException : InvalidOperationException + { + /// + /// Constructor + /// + /// The localized error message string + 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 index 0000000..e89de76 --- /dev/null +++ b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/LaunchRejectedException.cs @@ -0,0 +1,18 @@ +using System; + +namespace Tizen.Applications.Exceptions +{ + /// + /// The class that represents the exception which will be thrown when the launch request is rejected + /// + public class LaunchRejectedException : InvalidOperationException + { + /// + /// Constructor + /// + /// The localized error message string + 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 index 0000000..f6c5967 --- /dev/null +++ b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/OutOfMemoryException.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Tizen.Applications.Exceptions +{ + /// + /// The class that represents the exception which will be thrown when the memory is insufficient + /// + public class OutOfMemoryException : InvalidOperationException + { + /// + /// Constructor + /// + /// The localized error message string + 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 index 0000000..015ae13 --- /dev/null +++ b/src/Tizen.Applications.Common/Tizen.Applications.Exceptions/PermissionDeniedException.cs @@ -0,0 +1,18 @@ +using System; + +namespace Tizen.Applications.Exceptions +{ + /// + /// The class that represents the exception which will be thrown when the permission is denied + /// + public class PermissionDeniedException : InvalidOperationException + { + /// + /// Constructor + /// + /// The localized error message string + public PermissionDeniedException(string message) : base(message) + { + } + } +} diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs index fd4c79c..a0e1f88 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs @@ -501,7 +501,11 @@ namespace Tizen.Applications /// The AppControl. /// The callback function to be called when the reply is delivered. /// Thrown when failed because of the argument is invalid. - /// Thrown when failed because of an invalid operation. + /// Thrown when the application to run is not found. + /// Thrown when the request failed to launch the application. + /// Thrown when the launch request is rejected. + /// Thrown when the memory is insufficient. + /// Thrown when the permission is denied. /// Thrown when failed because of timeout. /// http://tizen.org/privilege/appmanager.launch /// @@ -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"); } } } -- 2.7.4