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.
19 namespace Tizen.Pims.Calendar
21 internal enum CalendarError
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,
39 internal static class Globals
41 internal const string LogTag = "Tizen.Pims.Calendar";
42 internal const int ErrorCalendar = -0x02000000;
45 internal static class CalendarErrorFactory
47 internal static void ThrowException(int e)
49 throw GetException(e);
52 internal static Exception GetException(int e)
55 switch ((CalendarError)e)
57 case CalendarError.OutOfMemory:
58 exp = new OutOfMemoryException("Out of memory");
59 Log.Error(Globals.LogTag, "Out of memory");
61 case CalendarError.InvalidParameter:
62 exp = new ArgumentException("Invalid parameter");
63 Log.Error(Globals.LogTag, "Invalid parameter");
65 case CalendarError.FileNoSpace:
66 exp = new InvalidOperationException("File no space Error");
67 Log.Error(Globals.LogTag, "File no space Error");
69 case CalendarError.PermissionDenied:
70 exp = new UnauthorizedAccessException("Permission denied");
71 Log.Error(Globals.LogTag, "Permission denied");
73 case CalendarError.NotSupported:
74 exp = new NotSupportedException("Not supported");
75 Log.Error(Globals.LogTag, "Not supported");
77 case CalendarError.NoData:
78 exp = new InvalidOperationException("No data found");
79 Log.Error(Globals.LogTag, "No data found");
81 case CalendarError.DBLocked:
82 exp = new InvalidOperationException("DB locked");
83 Log.Error(Globals.LogTag, "DB locked");
85 case CalendarError.ErrorDB:
86 exp = new InvalidOperationException("DB error");
87 Log.Error(Globals.LogTag, "DB error");
89 case CalendarError.IPCNotAvailable:
90 exp = new InvalidOperationException("IPC not available");
91 Log.Error(Globals.LogTag, "IPC not available");
93 case CalendarError.ErrorIPC:
94 exp = new InvalidOperationException("IPC error");
95 Log.Error(Globals.LogTag, "IPC error");
97 case CalendarError.ErrorSystem:
98 exp = new InvalidOperationException("System error");
99 Log.Error(Globals.LogTag, "System error");
101 case CalendarError.ErrorInternal:
102 exp = new InvalidOperationException("Internal error");
103 Log.Error(Globals.LogTag, "Internal error");
106 exp = new InvalidOperationException("Invalid operation");
107 Log.Error(Globals.LogTag, "Invalid operation");