Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Messaging.Push / Tizen.Messaging.Push / PushExceptionFactory.cs
1  /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Collections.Generic;
19 using System.Linq;
20 using System.Text;
21
22 namespace Tizen.Messaging.Push
23 {
24     class PushExceptionFactory
25     {
26         internal static Exception CreateResponseException(Interop.PushClient.ServiceError result)
27         {
28             Exception exp;
29             switch (result)
30             {
31                 case Interop.PushClient.ServiceError.OutOfMemory:
32                 {
33                     Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.PushClient.ServiceError.OutOfMemory");
34                     exp = new InvalidOperationException("Memory Not Sufficient for the current operation");
35                     break;
36                 }
37                 case Interop.PushClient.ServiceError.InvalidParameter:
38                 {
39                     Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.PushClient.ServiceError.InvalidParameter");
40                     exp = new InvalidOperationException("The Parameter Passed was Invalid or Invalid Operation Intented");
41                     break;
42                 }
43                 case Interop.PushClient.ServiceError.NotConnected:
44                 {
45                     Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.PushClient.ServiceError.NotConnected");
46                     exp = new InvalidOperationException("Not Connected to Server");
47                     break;
48                 }
49                 case Interop.PushClient.ServiceError.NoData:
50                 {
51                     Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.PushClient.ServiceError.NoData");
52                     exp = new InvalidOperationException("No Data");
53                     break;
54                 }
55                 case Interop.PushClient.ServiceError.OpearationFailed:
56                 {
57                     Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.PushClient.ServiceError.OpearationFailed");
58                     exp = new InvalidOperationException("Operation Failed");
59                     break;
60                 }
61                 case Interop.PushClient.ServiceError.PermissionDenied:
62                 {
63                     Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.PushClient.ServiceError.PermissionDenied");
64                     exp = new InvalidOperationException("Permission Denied");
65                     break;
66                 }
67                 case Interop.PushClient.ServiceError.NotSupported:
68                 {
69                     Tizen.Log.Error(Interop.PushClient.LogTag, "Interop.PushClient.ServiceError.NotSupported");
70                     exp = new InvalidOperationException("Not Supported");
71                     break;
72                 }
73                 default:
74                 {
75                     Tizen.Log.Error(Interop.PushClient.LogTag, "Creating Exception for Default case for error code " + result);
76                     exp = new Exception();
77                     break;
78                 }
79             }
80             return exp;
81         }
82     }
83 }