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 System.Collections.Generic;
21 using System.Threading.Tasks;
23 namespace Tizen.Network.Connection
25 internal static class ConnectionErrorFactory
27 internal static void CheckFeatureUnsupportedException(int err, string message)
29 if ((ConnectionError)err == ConnectionError.NotSupported)
31 ThrowConnectionException(err, message);
35 internal static void CheckPermissionDeniedException(int err, string message)
37 if ((ConnectionError)err == ConnectionError.PermissionDenied)
39 ThrowConnectionException(err, message);
43 internal static void CheckHandleNullException(int err, bool isHandleInvalid, string message)
45 if ((ConnectionError)err == ConnectionError.InvalidParameter)
49 ThrowConnectionException((int)ConnectionError.InvalidOperation, message);
54 internal static void ThrowConnectionException(int errno , string message = "")
56 ConnectionError _error = (ConnectionError)errno;
57 Log.Debug(Globals.LogTag, "ThrowConnectionException " + _error);
60 case ConnectionError.AddressFamilyNotSupported:
61 throw new InvalidOperationException("Address Family Not Supported");
62 case ConnectionError.AlreadyExists:
63 throw new InvalidOperationException("Already Exists");
64 case ConnectionError.DhcpFailed:
65 throw new InvalidOperationException("DHCP Failed");
66 case ConnectionError.EndOfIteration:
67 throw new InvalidOperationException("End Of Iteration");
68 case ConnectionError.InvalidKey:
69 throw new InvalidOperationException("Invalid Key");
70 case ConnectionError.InvalidOperation:
71 throw new InvalidOperationException("Invalid Operation " + message);
72 case ConnectionError.InvalidParameter:
73 throw new ArgumentException("Invalid Parameter");
74 case ConnectionError.NoConnection:
75 throw new InvalidOperationException("No Connection");
76 case ConnectionError.NoReply:
77 throw new InvalidOperationException("No Reply");
78 case ConnectionError.NotSupported:
79 throw new NotSupportedException("Unsupported feature " + message);
80 case ConnectionError.NowInProgress:
81 throw new InvalidOperationException("Now In Progress");
82 case ConnectionError.OperationAborted:
83 throw new InvalidOperationException("Operation Aborted");
84 case ConnectionError.OperationFailed:
85 throw new InvalidOperationException("Operation Failed");
86 case ConnectionError.OutOfMemoryError:
87 throw new OutOfMemoryException("Out Of Memory Error");
88 case ConnectionError.PermissionDenied:
89 throw new UnauthorizedAccessException("Permission Denied " + message);