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 /// <since_tizen> 3 </since_tizen>
32 public enum LocationError
37 None = ErrorCode.None,
40 /// Out of memory error.
42 OutOfMemory = ErrorCode.OutOfMemory,
45 /// Invalid parameter.
47 InvalidParameter = ErrorCode.InvalidParameter,
50 /// Permission denied.
52 AcessibilityNotallowed = ErrorCode.PermissionDenied,
55 /// Address family not supported.
57 NotSupported = ErrorCode.NotSupported,
60 /// Location manager contains incorrect method for a given call.
62 IncorrectMethod = LocationManagerError.Base | 0x01,
65 /// Network unavailable.
67 NetworkFailed = LocationManagerError.Base | 0x02,
70 /// Location service is not available.
72 ServiceNotAvailable = LocationManagerError.Base | 0x03,
75 /// GPS/WPS, or MOCK setting is not enabled.
77 SettingOff = LocationManagerError.Base | 0x04,
80 /// Restricted by security system policy.
82 SecuirtyRestricted = LocationManagerError.Base | 0x05,
86 /// Location Boundary error codes.
88 /// <since_tizen> 3 </since_tizen>
89 public enum LocationBoundError
95 None = ErrorCode.None,
98 /// Out of memory error.
100 OutOfMemory = ErrorCode.OutOfMemory,
103 /// Invalid parameter.
105 InvalidParameter = ErrorCode.InvalidParameter,
110 NotSupported = ErrorCode.NotSupported,
113 /// Incorrect bounds type for a given call.
115 IncorrectType = LocationManagerError.BoundsBase | 0x01,
118 /// Cannot remove bounds handle from location manager.
120 IsAdded = LocationManagerError.BoundsBase | 0x02
123 internal static class LocationErrorFactory
125 internal static Exception ThrowLocationException(int errCode)
127 Log.Error(Globals.LogTag, "Throw Location Exception : " + errCode);
128 LocationError error = (LocationError)errCode;
131 case LocationError.OutOfMemory:
132 return new InvalidOperationException("Out of memory");
133 case LocationError.InvalidParameter:
134 return new ArgumentException("Invalid Parameter passed");
135 case LocationError.AcessibilityNotallowed:
136 return new UnauthorizedAccessException("Accesibility not allowed");
137 case LocationError.NotSupported:
138 return new NotSupportedException("Not supported");
139 case LocationError.IncorrectMethod:
140 return new InvalidOperationException("Incorrect method used");
141 case LocationError.NetworkFailed:
142 return new InvalidOperationException("Network failed");
143 case LocationError.ServiceNotAvailable:
144 return new InvalidOperationException("Service not available");
145 case LocationError.SettingOff:
146 return new InvalidOperationException("Current locationtype setting is off");
147 case LocationError.SecuirtyRestricted:
148 return new InvalidOperationException("Security Restricted");
150 return new InvalidOperationException("Unknown Error");
154 internal static Exception ThrowLocationBoundaryException(int errCode)
156 LocationBoundError error = (LocationBoundError)errCode;
159 case LocationBoundError.OutOfMemory:
160 return new InvalidOperationException("Out of memory exception");
161 case LocationBoundError.InvalidParameter:
162 return new ArgumentException("Invalid parameter passed");
163 case LocationBoundError.NotSupported:
164 return new NotSupportedException("Not supported");
165 case LocationBoundError.IncorrectType:
166 return new InvalidOperationException("Incorrect type passed");
167 case LocationBoundError.IsAdded:
168 return new InvalidOperationException("Boundary is not addded");
170 return new InvalidOperationException("Unknown Error");