/* * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using System; using Tizen; namespace Tizen.Account.AccountManager { /// /// Enumeration for the types of error occured, if any. /// /// 3 public enum AccountError { //TIZEN_ERROR_ACCOUNT = -0x01000000 /// /// Successful. /// /// 3 None = Tizen.Internals.Errors.ErrorCode.None, /// /// Invalid parameter. /// /// 3 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, /// /// Out of memory. /// /// 3 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /// /// Same user name exists in your application. /// /// 3 Duplcated = -0x01000000 | 0x01, /// /// Empty data. /// /// 3 NoData = Tizen.Internals.Errors.ErrorCode.NoData, /// /// Elated record does not exist. /// /// 3 RecordNotFound = -0x01000000 | 0x03, /// /// Invalid operation. /// /// 3 InvalidOperation = Tizen.Internals.Errors.ErrorCode.InvalidOperation, /// /// DB operation failed. /// /// 3 DBFailed = -0x01000000 | 0x04, /// /// DB is not connected. /// /// 3 DBNotOpened = -0x01000000 | 0x05, /// /// DB query syntax error. /// /// 3 QuerySyntaxError = -0x01000000 | 0x06, /// /// Iterator has reached the end. /// /// 3 IteratorEnd = -0x01000000 | 0x07, /// /// Notification failed. /// /// 3 NotificationFailed = -0x01000000 | 0x08, /// /// Permission denied. /// /// 3 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, /// /// XML parse failed. /// /// 3 XMLParseFailed = -0x01000000 | 0x0a, /// /// XML file not found. /// /// 3 XMLFileNotFound = -0x01000000 | 0x0b, /// /// Subscription failed /// /// 3 EventSubscriptionFailed = -0x01000000 | 0x0c, /// /// Account provider is not registered. /// /// 3 ProviderNotRegistered = -0x01000000 | 0x0d, /// /// Multiple accounts are not supported. /// /// 3 MultipleNotAllowed = -0x01000000 | 0x0e, /// /// SQLite busy handler expired. /// /// 3 DBBusy = -0x01000000 | 0x10 }; internal class AccountErrorFactory { internal const string LogTag = "Tizen.Account.AccountManager"; internal static Exception CreateException(AccountError err, string msg) { Log.Info(LogTag, "Got Error " + err + " throwing Exception with msg " + msg); Exception exp; switch (err) { case AccountError.InvalidParameter: { exp = new ArgumentException(msg + " Invalid Parameters Provided"); break; } case AccountError.OutOfMemory: { exp = new OutOfMemoryException(msg + " Out Of Memory"); break; } case AccountError.InvalidOperation: { exp = new InvalidOperationException(msg + " Inavlid operation"); break; } case AccountError.NoData: { exp = new InvalidOperationException(msg + " Empty Data"); break; } case AccountError.PermissionDenied: { exp = new UnauthorizedAccessException(msg + " Permission Denied"); break; } case AccountError.DBFailed: { exp = new InvalidOperationException(msg + " DataBase Failed"); break; } case AccountError.DBBusy: { exp = new InvalidOperationException(msg + " DataBase Busy"); break; } case AccountError.QuerySyntaxError: { exp = new InvalidOperationException(msg + " Network Error"); break; } case AccountError.XMLFileNotFound: { exp = new System.IO.FileNotFoundException(msg + " XML File not found"); break; } case AccountError.XMLParseFailed: { exp = new System.IO.InvalidDataException(msg + " XML parse error"); break; } default: { exp = new InvalidOperationException(err + " " + msg); break; } } return exp; } } }