[C# Connection] Adding C# Connection code
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Connection / Tizen.Network.Connection / ConnectionError.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 using System;
18 using System.Collections.Generic;
19 using System.Linq;
20 using System.Text;
21 using System.Threading.Tasks;
22
23 namespace Tizen.Network.Connection
24 {
25     internal class ConnectionErrorFactory
26     {
27         static public void ThrowConnectionException(int errno)
28         {
29             ConnectionError error = (ConnectionError)errno;
30             if (error == ConnectionError.AddressFamilyNotSupported)
31             {
32                 throw new InvalidOperationException("Address Family Not Supported");
33             }
34             else if (error == ConnectionError.AlreadyExists)
35             {
36                 throw new InvalidOperationException("Already Exists");
37             }
38             else if (error == ConnectionError.DhcpFailed)
39             {
40                 throw new InvalidOperationException("DHCP Failed");
41             }
42             else if (error == ConnectionError.EndOfIteration)
43             {
44                 throw new InvalidOperationException("End Of Iteration");
45             }
46             else if (error == ConnectionError.InvalidKey)
47             {
48                 throw new InvalidOperationException("Invalid Key");
49             }
50             else if (error == ConnectionError.InvalidOperation)
51             {
52                 throw new InvalidOperationException("Invalid Operation");
53             }
54             else if (error == ConnectionError.InvalidParameter)
55             {
56                 throw new InvalidOperationException("Invalid Parameter");
57             }
58             else if (error == ConnectionError.NoConnection)
59             {
60                 throw new InvalidOperationException("No Connection");
61             }
62             else if (error == ConnectionError.NoReply)
63             {
64                 throw new InvalidOperationException("No Reply");
65             }
66             else if (error == ConnectionError.NotSupported)
67             {
68                 throw new NotSupportedException("Not Supported");
69             }
70             else if (error == ConnectionError.NowInProgress)
71             {
72                 throw new InvalidOperationException("Now In Progress");
73             }
74             else if (error == ConnectionError.OperationAborted)
75             {
76                 throw new InvalidOperationException("Operation Aborted");
77             }
78             else if (error == ConnectionError.OperationFailed)
79             {
80                 throw new InvalidOperationException("Operation Failed");
81             }
82             else if (error == ConnectionError.OutOfMemoryError)
83             {
84                 throw new InvalidOperationException("Out Of Memory Error");
85             }
86             else if (error == ConnectionError.PermissionDenied)
87             {
88                 throw new InvalidOperationException("Permission Denied");
89             }
90         }
91     }
92 }