Fix XML documentation warnings
[platform/core/csapi/tizenfx.git] / src / Tizen.Pims.Calendar / Tizen.Pims.Calendar / CalendarErrorFactory.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
19 namespace Tizen.Pims.Calendar
20 {
21     internal enum CalendarError
22     {
23         None = Tizen.Internals.Errors.ErrorCode.None,
24         OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
25         InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
26         FileNoSpace = Tizen.Internals.Errors.ErrorCode.FileNoSpaceOnDevice,
27         PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
28         NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
29         NoData = Tizen.Internals.Errors.ErrorCode.NoData,
30         DBLocked = Globals.ErrorCalendar | 0x81,
31         ErrorDB = Globals.ErrorCalendar | 0x9F,
32         IPCNotAvailable = Globals.ErrorCalendar | 0xB1,
33         ErrorIPC = Globals.ErrorCalendar | 0xBF,
34         ErrorSystem = Globals.ErrorCalendar | 0xEF,
35         ErrorInternal = Globals.ErrorCalendar | 0x04,
36         DBNotFound = Globals.ErrorCalendar | 0x05,
37     };
38
39     internal static class Globals
40     {
41         internal const string LogTag = "Tizen.Pims.Calendar";
42         internal const int ErrorCalendar = -0x02000000;
43     }
44
45     internal static class CalendarErrorFactory
46     {
47         internal static void ThrowException(int e)
48         {
49             throw GetException(e);
50         }
51
52         internal static Exception GetException(int e)
53         {
54             Exception exp;
55             switch ((CalendarError)e)
56             {
57             case CalendarError.OutOfMemory:
58                 exp = new OutOfMemoryException("Out of memory");
59                 Log.Error(Globals.LogTag, "Out of memory");
60                 break;
61             case CalendarError.InvalidParameter:
62                 exp = new ArgumentException("Invalid parameter");
63                 Log.Error(Globals.LogTag, "Invalid parameter");
64                 break;
65             case CalendarError.FileNoSpace:
66                 exp = new InvalidOperationException("File no space Error");
67                 Log.Error(Globals.LogTag, "File no space Error");
68                 break;
69             case CalendarError.PermissionDenied:
70                 exp = new UnauthorizedAccessException("Permission denied");
71                 Log.Error(Globals.LogTag, "Permission denied");
72                 break;
73             case CalendarError.NotSupported:
74                 exp = new NotSupportedException("Not supported");
75                 Log.Error(Globals.LogTag, "Not supported");
76                 break;
77             case CalendarError.NoData:
78                 exp = new InvalidOperationException("No data found");
79                 Log.Error(Globals.LogTag, "No data found");
80                 break;
81             case CalendarError.DBLocked:
82                 exp = new InvalidOperationException("DB locked");
83                 Log.Error(Globals.LogTag, "DB locked");
84                 break;
85             case CalendarError.ErrorDB:
86                 exp = new InvalidOperationException("DB error");
87                 Log.Error(Globals.LogTag, "DB error");
88                 break;
89             case CalendarError.IPCNotAvailable:
90                 exp = new InvalidOperationException("IPC not available");
91                 Log.Error(Globals.LogTag, "IPC not available");
92                 break;
93             case CalendarError.ErrorIPC:
94                 exp = new InvalidOperationException("IPC error");
95                 Log.Error(Globals.LogTag, "IPC error");
96                 break;
97             case CalendarError.ErrorSystem:
98                 exp = new InvalidOperationException("System error");
99                 Log.Error(Globals.LogTag, "System error");
100                 break;
101             case CalendarError.ErrorInternal:
102                 exp = new InvalidOperationException("Internal error");
103                 Log.Error(Globals.LogTag, "Internal error");
104                 break;
105             default:
106                 exp = new InvalidOperationException("Invalid operation");
107                 Log.Error(Globals.LogTag, "Invalid operation");
108                 break;
109             }
110             return exp;
111         }
112     }
113 }