2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using Tizen.Internals.Errors;
20 namespace Tizen.Pims.Calendar
22 internal enum CalendarError
24 None = Tizen.Internals.Errors.ErrorCode.None, /**< Successful */
25 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /**< Out of Memory (-12) */
26 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, /**< Invalid parameter (-22) */
27 FileNoSpace = Tizen.Internals.Errors.ErrorCode.FileNoSpaceOnDevice, /** <FS Full (-28) */
28 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, /**< Permission denied (-13) */
29 NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, /**< Not supported (-1073741822) */
30 NoData = Tizen.Internals.Errors.ErrorCode.NoData, /**< Requested data does not exist (-61) */
31 DBLocked = Globals.ErrorCalendar | 0x81, /**< Database table locked or file locked (-33619839) */
32 ErrorDB = Globals.ErrorCalendar | 0x9F, /**< Unknown DB error (-33619809) */
33 IPCNotAvailable = Globals.ErrorCalendar | 0xB1, /**< IPC server is not available (-33619791) */
34 ErrorIPC = Globals.ErrorCalendar | 0xBF, /**< Unknown IPC error (-33619777) */
35 ErrorSystem = Globals.ErrorCalendar | 0xEF, /**< Internal system module error (-33619729) */
36 ErrorInternal = Globals.ErrorCalendar | 0x04, /**< Implementation Error Temporary Use (-33619713) */
37 DBNotFound = Globals.ErrorCalendar | 0x05, /**< No data in DB (-33554427) */
40 internal static class Globals
42 internal const string LogTag = "Tizen.Pims.Calendar";
43 internal const int ErrorCalendar = -0x02000000;
46 internal static class CalendarErrorFactory
48 internal static void ThrowException(int e)
50 throw GetException(e);
53 internal static Exception GetException(int e)
56 switch ((CalendarError)e)
58 case CalendarError.OutOfMemory:
59 exp = new OutOfMemoryException("Out of memory");
60 Log.Error(Globals.LogTag, "Out of memory");
62 case CalendarError.InvalidParameter:
63 exp = new ArgumentException("Invalid parameter");
64 Log.Error(Globals.LogTag, "Invalid parameter");
66 case CalendarError.FileNoSpace:
67 exp = new InvalidOperationException("File no space Error");
68 Log.Error(Globals.LogTag, "File no space Error");
70 case CalendarError.PermissionDenied:
71 exp = new UnauthorizedAccessException("Permission denied");
72 Log.Error(Globals.LogTag, "Permission denied");
74 case CalendarError.NotSupported:
75 exp = new NotSupportedException("Not supported");
76 Log.Error(Globals.LogTag, "Not supported");
78 case CalendarError.NoData:
79 exp = new InvalidOperationException("No data found");
80 Log.Error(Globals.LogTag, "No data found");
82 case CalendarError.DBLocked:
83 exp = new InvalidOperationException("DB locked");
84 Log.Error(Globals.LogTag, "DB locked");
86 case CalendarError.ErrorDB:
87 exp = new InvalidOperationException("DB error");
88 Log.Error(Globals.LogTag, "DB error");
90 case CalendarError.IPCNotAvailable:
91 exp = new InvalidOperationException("IPC not available");
92 Log.Error(Globals.LogTag, "IPC not available");
94 case CalendarError.ErrorIPC:
95 exp = new InvalidOperationException("IPC error");
96 Log.Error(Globals.LogTag, "IPC error");
98 case CalendarError.ErrorSystem:
99 exp = new InvalidOperationException("System error");
100 Log.Error(Globals.LogTag, "System error");
102 case CalendarError.ErrorInternal:
103 exp = new InvalidOperationException("Internal error");
104 Log.Error(Globals.LogTag, "Internal error");
107 exp = new InvalidOperationException("Invalid operation");
108 Log.Error(Globals.LogTag, "Invalid operation");