/
LocationError.cs
executable file
·174 lines (153 loc) · 5.9 KB
/
LocationError.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
* 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;
}
/// <summary>
/// Location Manager error codes.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public enum LocationError
{
/// <summary>
/// Successful.
/// </summary>
None = ErrorCode.None,
/// <summary>
/// Out of memory error.
/// </summary>
OutOfMemory = ErrorCode.OutOfMemory,
/// <summary>
/// Invalid parameter.
/// </summary>
InvalidParameter = ErrorCode.InvalidParameter,
/// <summary>
/// Permission denied.
/// </summary>
AcessibilityNotallowed = ErrorCode.PermissionDenied,
/// <summary>
/// Address family not supported.
/// </summary>
NotSupported = ErrorCode.NotSupported,
/// <summary>
/// Location manager contains incorrect method for a given call.
/// </summary>
IncorrectMethod = LocationManagerError.Base | 0x01,
/// <summary>
/// Network unavailable.
/// </summary>
NetworkFailed = LocationManagerError.Base | 0x02,
/// <summary>
/// Location service is not available.
/// </summary>
ServiceNotAvailable = LocationManagerError.Base | 0x03,
/// <summary>
/// GPS/WPS, or MOCK setting is not enabled.
/// </summary>
SettingOff = LocationManagerError.Base | 0x04,
/// <summary>
/// Restricted by security system policy.
/// </summary>
SecuirtyRestricted = LocationManagerError.Base | 0x05,
}
/// <summary>
/// Location Boundary error codes.
/// </summary>
/// <since_tizen> 3 </since_tizen>
public enum LocationBoundError
{
/// <summary>
/// Successful.
/// </summary>
None = ErrorCode.None,
/// <summary>
/// Out of memory error.
/// </summary>
OutOfMemory = ErrorCode.OutOfMemory,
/// <summary>
/// Invalid parameter.
/// </summary>
InvalidParameter = ErrorCode.InvalidParameter,
/// <summary>
/// Not supported.
/// </summary>
NotSupported = ErrorCode.NotSupported,
/// <summary>
/// Incorrect bounds type for a given call.
/// </summary>
IncorrectType = LocationManagerError.BoundsBase | 0x01,
/// <summary>
/// Cannot remove bounds handle from location manager.
/// </summary>
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");
}
}
}
}