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;
19 using System.Threading.Tasks;
20 using System.Threading;
22 namespace Tizen.Convergence
24 internal enum ConvErrorCode
26 None = ErrorCode.None,
27 OutOfMemory = ErrorCode.OutOfMemory,
28 InvalidParameter = ErrorCode.InvalidParameter,
29 InvalidOperation = ErrorCode.InvalidOperation,
30 NoData = ErrorCode.NoData,
31 NotSupported = ErrorCode.NotSupported,
32 PermissionDenied = ErrorCode.PermissionDenied,
35 internal class ErrorFactory
37 internal static string LogTag = "Tizen.Convergence";
39 internal static Exception GetException(int error)
41 if ((ConvErrorCode)error == ConvErrorCode.OutOfMemory)
43 return new OutOfMemoryException("Out of memory");
45 else if ((ConvErrorCode)error == ConvErrorCode.InvalidParameter)
47 return new ArgumentException("Invalid parameter");
49 else if ((ConvErrorCode)error == ConvErrorCode.InvalidOperation)
51 return new InvalidOperationException("Invalid operation");
53 else if ((ConvErrorCode)error == ConvErrorCode.NotSupported)
55 return new NotSupportedException("Unsupported feature http://tizen.org/feature/convergence.d2d");
57 else if ((ConvErrorCode)error == ConvErrorCode.PermissionDenied)
59 return new UnauthorizedAccessException("Permission denied. (http://tizen.org/privilege/internet, http://tizen.org/privilege/bluetooth, http://tizen.org/privilege/d2d.datasharing)");
61 else if ((ConvErrorCode)error == ConvErrorCode.NoData)
63 return new InvalidOperationException("The payload is empty");
67 return new Exception("Unknown error");