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.Sensor
22 internal enum SensorError
24 None = ErrorCode.None,
25 IOError = ErrorCode.IoError,
26 InvalidParameter = ErrorCode.InvalidParameter,
27 NotSupported = ErrorCode.NotSupported,
28 PermissionDenied = ErrorCode.PermissionDenied,
29 OutOfMemory = ErrorCode.OutOfMemory,
30 NotNeedCalibration = -0x02440000 | 0x03,
31 OperationFailed = -0x02440000 | 0x06
34 internal static class SensorErrorFactory
36 static internal Exception CheckAndThrowException(int error, string msg)
38 SensorError e = (SensorError)error;
41 case SensorError.None:
43 case SensorError.IOError:
44 return new InvalidOperationException("I/O Error: " + msg);
45 case SensorError.InvalidParameter:
46 return new ArgumentException("Invalid Parameter: " + msg);
47 case SensorError.NotSupported:
48 return new NotSupportedException("Not Supported: " + msg);
49 case SensorError.PermissionDenied:
50 return new UnauthorizedAccessException("Permission Denied: " + msg);
51 case SensorError.OutOfMemory:
52 return new InvalidOperationException("Out of Memory: " + msg);
53 case SensorError.NotNeedCalibration:
54 return new InvalidOperationException("Sensor doesn't need calibration: " + msg);
55 case SensorError.OperationFailed:
56 return new InvalidOperationException("Operation Failed: " + msg);
58 return new InvalidOperationException("Unknown Error Code: " + msg);