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