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.
20 namespace Tizen.Account.AccountManager
23 /// Enumeration for the types of error occured, if any.
25 /// <since_tizen> 3 </since_tizen>
26 public enum AccountError
28 //TIZEN_ERROR_ACCOUNT = -0x01000000
32 /// <since_tizen> 3 </since_tizen>
33 None = Tizen.Internals.Errors.ErrorCode.None,
35 /// Invalid parameter.
37 /// <since_tizen> 3 </since_tizen>
38 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
42 /// <since_tizen> 3 </since_tizen>
43 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
45 /// Same user name exists in your application.
47 /// <since_tizen> 3 </since_tizen>
48 Duplcated = -0x01000000 | 0x01,
52 /// <since_tizen> 3 </since_tizen>
53 NoData = Tizen.Internals.Errors.ErrorCode.NoData,
55 /// Elated record does not exist.
57 /// <since_tizen> 3 </since_tizen>
58 RecordNotFound = -0x01000000 | 0x03,
60 /// Invalid operation.
62 /// <since_tizen> 3 </since_tizen>
63 InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation,
65 /// DB operation failed.
67 /// <since_tizen> 3 </since_tizen>
68 DBFailed = -0x01000000 | 0x04,
70 /// DB is not connected.
72 /// <since_tizen> 3 </since_tizen>
73 DBNotOpened = -0x01000000 | 0x05,
75 /// DB query syntax error.
77 /// <since_tizen> 3 </since_tizen>
78 QuerySyntaxError = -0x01000000 | 0x06,
80 /// Iterator has reached the end.
82 /// <since_tizen> 3 </since_tizen>
83 IteratorEnd = -0x01000000 | 0x07,
85 /// Notification failed.
87 /// <since_tizen> 3 </since_tizen>
88 NotificationFailed = -0x01000000 | 0x08,
90 /// Permission denied.
92 /// <since_tizen> 3 </since_tizen>
93 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
97 /// <since_tizen> 3 </since_tizen>
98 XMLParseFailed = -0x01000000 | 0x0a,
100 /// XML file not found.
102 /// <since_tizen> 3 </since_tizen>
103 XMLFileNotFound = -0x01000000 | 0x0b,
105 /// Subscription failed
107 /// <since_tizen> 3 </since_tizen>
108 EventSubscriptionFailed = -0x01000000 | 0x0c,
110 /// Account provider is not registered.
112 /// <since_tizen> 3 </since_tizen>
113 ProviderNotRegistered = -0x01000000 | 0x0d,
115 /// Multiple accounts are not supported.
117 /// <since_tizen> 3 </since_tizen>
118 MultipleNotAllowed = -0x01000000 | 0x0e,
120 /// SQLite busy handler expired.
122 /// <since_tizen> 3 </since_tizen>
123 DBBusy = -0x01000000 | 0x10
126 internal class AccountErrorFactory
128 internal const string LogTag = "Tizen.Account.AccountManager";
130 internal static Exception CreateException(AccountError err, string msg)
132 Log.Info(LogTag, "Got Error " + err + " throwing Exception with msg " + msg);
136 case AccountError.InvalidParameter:
138 exp = new ArgumentException(msg + " Invalid Parameters Provided");
142 case AccountError.OutOfMemory:
144 exp = new OutOfMemoryException(msg + " Out Of Memory");
148 case AccountError.InvalidOperation:
150 exp = new InvalidOperationException(msg + " Inavlid operation");
154 case AccountError.NoData:
156 exp = new InvalidOperationException(msg + " Empty Data");
160 case AccountError.PermissionDenied:
162 exp = new UnauthorizedAccessException(msg + " Permission Denied");
166 case AccountError.DBFailed:
168 exp = new InvalidOperationException(msg + " DataBase Failed");
172 case AccountError.DBBusy:
174 exp = new InvalidOperationException(msg + " DataBase Busy");
178 case AccountError.QuerySyntaxError:
180 exp = new InvalidOperationException(msg + " Network Error");
183 case AccountError.XMLFileNotFound:
185 exp = new System.IO.FileNotFoundException(msg + " XML File not found");
188 case AccountError.XMLParseFailed:
190 exp = new System.IO.InvalidDataException(msg + " XML parse error");
196 exp = new InvalidOperationException(err + " " + msg);