/* * 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.Internals.Errors; namespace Tizen.Location { internal static class LocationManagerError { public const int Base = -0x02C00000; public const int BoundsBase = -0x02C00000 | 0x20; } /// /// Location Manager error codes. /// /// 3 public enum LocationError { /// /// Successful. /// None = ErrorCode.None, /// /// Out of memory error. /// OutOfMemory = ErrorCode.OutOfMemory, /// /// Invalid parameter. /// InvalidParameter = ErrorCode.InvalidParameter, /// /// Permission denied. /// AcessibilityNotallowed = ErrorCode.PermissionDenied, /// /// Address family not supported. /// NotSupported = ErrorCode.NotSupported, /// /// Location manager contains incorrect method for a given call. /// IncorrectMethod = LocationManagerError.Base | 0x01, /// /// Network unavailable. /// NetworkFailed = LocationManagerError.Base | 0x02, /// /// Location service is not available. /// ServiceNotAvailable = LocationManagerError.Base | 0x03, /// /// GPS/WPS, or MOCK setting is not enabled. /// SettingOff = LocationManagerError.Base | 0x04, /// /// Restricted by security system policy. /// SecuirtyRestricted = LocationManagerError.Base | 0x05, } /// /// Location Boundary error codes. /// /// 3 public enum LocationBoundError { /// /// Successful. /// None = ErrorCode.None, /// /// Out of memory error. /// OutOfMemory = ErrorCode.OutOfMemory, /// /// Invalid parameter. /// InvalidParameter = ErrorCode.InvalidParameter, /// /// Not supported. /// NotSupported = ErrorCode.NotSupported, /// /// Incorrect bounds type for a given call. /// IncorrectType = LocationManagerError.BoundsBase | 0x01, /// /// Cannot remove bounds handle from location manager. /// IsAdded = LocationManagerError.BoundsBase | 0x02 } internal static class LocationErrorFactory { internal static Exception ThrowLocationException(int errCode) { Log.Error(Globals.LogTag, "Throw Location Exception : " + errCode); LocationError error = (LocationError)errCode; switch (error) { case LocationError.OutOfMemory: return new InvalidOperationException("Out of memory"); case LocationError.InvalidParameter: return new ArgumentException("Invalid Parameter passed"); case LocationError.AcessibilityNotallowed: return new UnauthorizedAccessException("Accesibility not allowed"); case LocationError.NotSupported: return new NotSupportedException("Not supported"); case LocationError.IncorrectMethod: return new InvalidOperationException("Incorrect method used"); case LocationError.NetworkFailed: return new InvalidOperationException("Network failed"); case LocationError.ServiceNotAvailable: return new InvalidOperationException("Service not available"); case LocationError.SettingOff: return new InvalidOperationException("Current locationtype setting is off"); case LocationError.SecuirtyRestricted: return new InvalidOperationException("Security Restricted"); default: return new InvalidOperationException("Unknown Error"); } } internal static Exception ThrowLocationBoundaryException(int errCode) { LocationBoundError error = (LocationBoundError)errCode; switch (error) { case LocationBoundError.OutOfMemory: return new InvalidOperationException("Out of memory exception"); case LocationBoundError.InvalidParameter: return new ArgumentException("Invalid parameter passed"); case LocationBoundError.NotSupported: return new NotSupportedException("Not supported"); case LocationBoundError.IncorrectType: return new InvalidOperationException("Incorrect type passed"); case LocationBoundError.IsAdded: return new InvalidOperationException("Boundary is not addded"); default: return new InvalidOperationException("Unknown Error"); } } } }