1 // Copyright 2016 by Samsung Electronics, Inc.,
3 // This software is the confidential and proprietary information
4 // of Samsung Electronics, Inc. ("Confidential Information"). You
5 // shall not disclose such Confidential Information and shall use
6 // it only in accordance with the terms of the license agreement
7 // you entered into with Samsung.
10 using Tizen.Internals.Errors;
12 namespace Tizen.Sensor
14 internal enum SensorError
16 None = ErrorCode.None,
17 IOError = ErrorCode.IoError,
18 InvalidParameter = ErrorCode.InvalidParameter,
19 NotSupported = ErrorCode.NotSupported,
20 PermissionDenied = ErrorCode.PermissionDenied,
21 OutOfMemory = ErrorCode.OutOfMemory,
22 NotNeedCalibration = -0x02440000 | 0x03,
23 OperationFailed = -0x02440000 | 0x06
26 internal static class SensorErrorFactory
28 static internal Exception CheckAndThrowException(int error, string msg)
30 SensorError e = (SensorError)error;
33 case SensorError.None:
35 case SensorError.IOError:
36 return new InvalidOperationException("I/O Error: " + msg);
37 case SensorError.InvalidParameter:
38 return new ArgumentException("Invalid Parameter: " + msg);
39 case SensorError.NotSupported:
40 return new NotSupportedException("Not Supported: " + msg);
41 case SensorError.PermissionDenied:
42 return new UnauthorizedAccessException("Permission Denied: " + msg);
43 case SensorError.OutOfMemory:
44 return new InvalidOperationException("Out of Memory: " + msg);
45 case SensorError.NotNeedCalibration:
46 return new InvalidOperationException("Sensor doesn't need calibration: " + msg);
47 case SensorError.OperationFailed:
48 return new InvalidOperationException("Operation Failed: " + msg);
50 return new InvalidOperationException("Unknown Error Code: " + msg);