/* * 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.Location.Geofence { /// /// Enumeration for the types of error occured, if any. /// /// 3 public enum GeofenceError { /// /// Successful. /// /// 3 None = Tizen.Internals.Errors.ErrorCode.None, /// /// Out of memory. /// /// 3 OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /// /// Invalid parameter. /// /// 3 InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter, /// /// Permission denied. /// /// 3 PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied, /// /// Not Supported. /// /// 3 NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported, /// /// Geofence manager is not initialized. /// /// 3 NotInitialized = -0x02C10000 | 0x01, /// /// Invalid geofence ID. /// /// 3 InvalidID = -0x02C10000 | 0x02, /// /// Exception occurs. /// /// 3 Exception = -0x02C10000 | 0x03, /// /// Geofencing is already started. /// /// 3 AlreadyStarted = -0x02C10000 | 0x04, /// /// Too many geofence. /// /// 3 TooManyGeofence = -0x02C10000 | 0x05, /// /// Error in GPS, Wi-Fi, or BT. /// /// 3 IPC = -0x02C10000 | 0x06, /// /// DB error in the server side. /// /// 3 DBFailed = -0x02C10000 | 0x07, /// /// Access to the specified place is denied. /// /// 3 PlaceAccessDenied = -0x02C10000 | 0x08, /// /// Access to the specified geofence is denied. /// /// 3 GeofenceAccessDenied = -0x02C10000 | 0x09 }; internal class GeofenceErrorFactory { internal const string LogTag = "Tizen.Location.Geofence"; internal static Exception CreateException(GeofenceError err, string msg) { Log.Info(LogTag, "Got Error " + err + " throwing Exception with msg " + msg); Exception exp; switch (err) { case GeofenceError.InvalidParameter: { exp = new ArgumentException(msg + " Invalid Parameters Provided"); break; } case GeofenceError.OutOfMemory: { exp = new OutOfMemoryException(msg + " Out Of Memory"); break; } case GeofenceError.NotInitialized: { exp = new InvalidOperationException(msg + " Not initializded"); break; } case GeofenceError.NotSupported: { exp = new NotSupportedException(msg + " Not supported"); break; } case GeofenceError.PermissionDenied: // fall through case GeofenceError.GeofenceAccessDenied: //fall through case GeofenceError.PlaceAccessDenied: { exp = new UnauthorizedAccessException(msg + " Permission Denied"); break; } case GeofenceError.DBFailed: { exp = new InvalidOperationException(msg + " DataBase Failed"); break; } default: { exp = new InvalidOperationException(msg); break; } } return exp; } } }