add exception handling for permission problem
authorKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 31 Mar 2017 07:25:54 +0000 (16:25 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Fri, 31 Mar 2017 07:31:42 +0000 (16:31 +0900)
Change-Id: I297374c4f5746200f67ebd9f524f2308ab795da6
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesErrorFactory.cs
src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManager.cs

index 1006097..c331aab 100755 (executable)
@@ -56,17 +56,18 @@ namespace Tizen.Messaging.Messages
                 throw new InvalidOperationException("Invalid instance (object may have been disposed or release)");
             }
 
-            if (err == MessagesError.InvalidParameter)
+            switch (err)
             {
-                throw new ArgumentException(err.ToString());
-            }
-            else if (err == MessagesError.NotSupported)
-            {
-                throw new NotSupportedException("Not supported");
-            }
-            else
-            {
-                throw new InvalidOperationException(err.ToString());
+                case MessagesError.OutOfMemory:
+                    throw new OutOfMemoryException(err.ToString());
+                case MessagesError.InvalidParameter:
+                    throw new ArgumentException(err.ToString());
+                case MessagesError.PermissionDenied:
+                    throw new UnauthorizedAccessException(err.ToString());
+                case MessagesError.NotSupported:
+                    throw new NotSupportedException(err.ToString());
+                default:
+                    throw new InvalidOperationException(err.ToString());
             }
         }
     }
index 8c25eb6..6b23ffa 100755 (executable)
@@ -36,6 +36,7 @@ namespace Tizen.Messaging.Messages
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
         /// <exception cref="NotSupportedException">Thrown when message service is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when input coordinates are invalid</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
         public static Task<SentResult> SendMessageAsync(Message message, bool saveToSentbox)
         {
             return MessagesManagerImpl.Instance.SendMessageAsync(message, saveToSentbox);
@@ -50,6 +51,8 @@ namespace Tizen.Messaging.Messages
         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
         /// <exception cref="NotSupportedException">Thrown when message service is not supported</exception>
         /// <exception cref="ArgumentException">Thrown when input coordinates are invalid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
         public static Task<IEnumerable<Message>> SearchMessageAsync(MessagesSearchFilter filter)
         {
             return MessagesManagerImpl.Instance.SearchMessageAsync(filter);