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.Contacts
22 internal enum ContactsError
24 None = (int)ErrorCode.None,
25 InvalidParameter = (int)ErrorCode.InvalidParameter,
26 NotSupported = (int)ErrorCode.NotSupported,
27 PermissionDenied = (int)ErrorCode.PermissionDenied,
28 OutOfMemory = (int)ErrorCode.OutOfMemory,
29 FileNoSpaceOnDevice = (int)ErrorCode.FileNoSpaceOnDevice,
30 NoData = (int)ErrorCode.NoData,
32 DatabaseLocked = -0x02010000 | 0x81,
33 Database = -0x02010000 | 0x9F,
34 IpcNotAvaliable = -0x02010000 | 0xB1,
35 Ipc = -0x02010000 | 0xBF,
36 System = -0x02010000 | 0xEF
39 internal static class Globals
41 internal const string LogTag = "Tizen.Pims.Contacts";
44 internal static class ContactsErrorFactory
46 static internal Exception CheckAndCreateException(int error)
48 ContactsError e = (ContactsError)error;
51 case ContactsError.None:
53 case ContactsError.InvalidParameter:
54 return new ArgumentException("Invalid Parameters Provided");
55 case ContactsError.NotSupported:
56 return new NotSupportedException("Not Supported");
57 case ContactsError.PermissionDenied:
58 return new UnauthorizedAccessException("Permission Denied");
59 case ContactsError.OutOfMemory:
60 return new OutOfMemoryException("Out of Memory");
61 case ContactsError.FileNoSpaceOnDevice:
62 return new InvalidOperationException("File System is Full");
63 case ContactsError.NoData:
64 return new InvalidOperationException("No Data");
65 case ContactsError.DatabaseLocked:
66 return new InvalidOperationException("Database Locked");
67 case ContactsError.Database:
68 return new InvalidOperationException("Database Failed");
69 case ContactsError.IpcNotAvaliable:
70 return new InvalidOperationException("IPC Not Avaliable");
71 case ContactsError.Ipc:
72 return new InvalidOperationException("IPC failed");
73 case ContactsError.System:
74 return new InvalidOperationException("Internal system error");
76 return new InvalidOperationException("Unknown Error Code");