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.Location
22 internal static class LocationManagerError
24 public const int Base = -0x02C00000;
25 public const int BoundsBase = -0x02C00000 | 0x20;
29 /// Location Manager error codes.
31 public enum LocationError
33 None = ErrorCode.None,/**< Successful */
34 OutOfMemory = ErrorCode.OutOfMemory,/**< Out of memory error */
35 InvalidParameter = ErrorCode.InvalidParameter,/**< Invalid parameter */
36 AcessibilityNotallowed = ErrorCode.PermissionDenied,/**< Permission denied */
37 NotSupported = ErrorCode.NotSupported,/**< Address family not supported */
38 IncorrectMethod = LocationManagerError.Base | 0x01,/**< Location manager contains incorrect method for a given call */
39 NetworkFailed = LocationManagerError.Base | 0x02,/**< Network unavailable */
40 ServiceNotAvailable = LocationManagerError.Base | 0x03,/**< Location service is not available */
41 SettingOff = LocationManagerError.Base | 0x04,/**< GPS/WPS, or MOCK setting is not enabled */
42 SecuirtyRestricted = LocationManagerError.Base | 0x05,/**< Restricted by security system policy */
46 /// Location Boundary error codes.
48 public enum LocationBoundError
50 None = ErrorCode.None,/**< Successful */
51 OutOfMemory = ErrorCode.OutOfMemory,/**< Out of memory error */
52 InvalidParameter = ErrorCode.InvalidParameter,/**< Invalid parameter */
53 NotSupported = ErrorCode.NotSupported,/**< Not supported */
54 IncorrectType = LocationManagerError.BoundsBase | 0x01,/**< Incorrect bounds type for a given call */
55 IsAdded = LocationManagerError.BoundsBase | 0x02/**< Cannot remove bounds handle from location manager */
58 internal static class LocationErrorFactory
60 internal static Exception ThrowLocationException(int errCode)
62 Log.Error(Globals.LogTag, "Throw Location Exception : " + errCode);
63 LocationError error = (LocationError)errCode;
66 case LocationError.OutOfMemory:
67 return new InvalidOperationException("Out of memory");
68 case LocationError.InvalidParameter:
69 return new ArgumentException("Invalid Parameter passed");
70 case LocationError.AcessibilityNotallowed:
71 return new UnauthorizedAccessException("Accesibility not allowed");
72 case LocationError.NotSupported:
73 return new NotSupportedException("Not supported");
74 case LocationError.IncorrectMethod:
75 return new InvalidOperationException("Incorrect method used");
76 case LocationError.NetworkFailed:
77 return new InvalidOperationException("Network failed");
78 case LocationError.ServiceNotAvailable:
79 return new InvalidOperationException("Service not available");
80 case LocationError.SettingOff:
81 return new InvalidOperationException("Current locationtype setting is off");
82 case LocationError.SecuirtyRestricted:
83 return new InvalidOperationException("Security Restricted");
85 return new InvalidOperationException("Unknown Error");
89 internal static Exception ThrowLocationBoundaryException(int errCode)
91 LocationBoundError error = (LocationBoundError)errCode;
94 case LocationBoundError.OutOfMemory:
95 return new InvalidOperationException("Out of memory exception");
96 case LocationBoundError.InvalidParameter:
97 return new ArgumentException("Invalid parameter passed");
98 case LocationBoundError.NotSupported:
99 return new NotSupportedException("Not supported");
100 case LocationBoundError.IncorrectType:
101 return new InvalidOperationException("Incorrect type passed");
102 case LocationBoundError.IsAdded:
103 return new InvalidOperationException("Boundary is not addded");
105 return new InvalidOperationException("Unknown Error");