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.
11 using Tizen.Internals.Errors;
13 namespace Tizen.Network.IoTConnectivity
15 internal enum IoTConnectivityError
17 None = ErrorCode.None,
18 InvalidParameter = ErrorCode.InvalidParameter,
19 OutOfMemory = ErrorCode.OutOfMemory,
20 Io = ErrorCode.IoError,
21 PermissionDenied = ErrorCode.PermissionDenied,
22 NotSupported = ErrorCode.NotSupported,
23 NoData = ErrorCode.NoData,
24 TimedOut = ErrorCode.TimedOut,
25 Iotivity = -0x01C80000 | 0x01,
26 Representation = -0x01C80000 | 0x02,
27 InvalidType = -0x01C80000 | 0x03,
28 Already = -0x01C80000 | 0x04,
29 System = -0x01C80000 | 0x06,
32 internal static class IoTConnectivityErrorFactory
34 internal const string LogTag = "Tizen.Network.IoTConnectivity";
36 internal static void ThrowException(int err)
38 throw GetException(err);
41 internal static Exception GetException(int err)
43 IoTConnectivityError error = (IoTConnectivityError)err;
44 if (error == IoTConnectivityError.OutOfMemory)
46 return new OutOfMemoryException("Out of memory");
48 else if (error == IoTConnectivityError.InvalidParameter)
50 return new ArgumentException("Invalid parameter");
52 else if (error == IoTConnectivityError.Io)
54 return new IOException("I/O Error");
56 else if (error == IoTConnectivityError.NoData)
58 return new InvalidOperationException("No data found");
60 else if (error == IoTConnectivityError.TimedOut)
62 return new TimeoutException("timed out");
64 else if (error == IoTConnectivityError.PermissionDenied)
66 return new UnauthorizedAccessException("Permission denied");
68 else if (error == IoTConnectivityError.NotSupported)
70 return new NotSupportedException("Not supported");
72 else if (error == IoTConnectivityError.Representation)
74 return new InvalidOperationException("Representation error");
76 else if (error == IoTConnectivityError.InvalidType)
78 return new ArgumentException("Invalid type");
80 else if (error == IoTConnectivityError.Already)
82 return new InvalidOperationException("Duplicate");
84 else if (error == IoTConnectivityError.System)
86 return new InvalidOperationException("System error");
90 return new InvalidOperationException("Invalid operation");