Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Bluetooth / Tizen.Network.Bluetooth / BluetoothError.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
19 namespace Tizen.Network.Bluetooth
20 {
21     static internal class BluetoothErrorFactory
22     {
23         static internal void ThrowBluetoothException(int exception)
24         {
25             BluetoothError error = (BluetoothError)exception;
26             switch (error)
27             {
28             case BluetoothError.InvalidParameter:
29                 throw new InvalidOperationException("Invalid parameter");
30
31             case BluetoothError.Cancelled:
32                 throw new InvalidOperationException("Operation cancelled");
33
34             case BluetoothError.AlreadyDone:
35                 throw new InvalidOperationException("Operation already done");
36
37             case BluetoothError.TimedOut:
38                 throw new InvalidOperationException("Timeout error");
39
40             case BluetoothError.AuthFailed:
41                 throw new InvalidOperationException("Authentication failed");
42
43             case BluetoothError.AuthRejected:
44                 throw new InvalidOperationException("Authentication rejected");
45
46             case BluetoothError.NoData:
47                 throw new InvalidOperationException("No data available");
48
49             case BluetoothError.NotEnabled:
50                 throw new InvalidOperationException("Local adapter not enabled");
51
52             case BluetoothError.NotInitialized:
53                 throw new InvalidOperationException("Local adapter not initialized");
54
55             case BluetoothError.NowInProgress:
56                 throw new InvalidOperationException("Operation now in progress");
57
58             case BluetoothError.NotInProgress:
59                 throw new InvalidOperationException("Operation not in progress");
60
61             case BluetoothError.NotSupported:
62                 throw new NotSupportedException("Bluetooth is not supported");
63
64             case BluetoothError.OperationFailed:
65                 throw new InvalidOperationException("Operation failed");
66
67             case BluetoothError.OutOfMemory:
68                 throw new InvalidOperationException("Out of memory");
69
70             case BluetoothError.PermissionDenied:
71                 throw new InvalidOperationException("Permission denied");
72
73             case BluetoothError.QuotaExceeded:
74                 throw new InvalidOperationException("Quota exceeded");
75
76             case BluetoothError.RemoteDeviceNotBonded:
77                 throw new InvalidOperationException("Remote device not bonded");
78
79             case BluetoothError.RemoteDeviceNotConnected:
80                 throw new InvalidOperationException("Remote device not connected");
81
82             case BluetoothError.RemoteDeviceNotFound:
83                 throw new InvalidOperationException("Remote device not found");
84
85             case BluetoothError.ResourceBusy:
86                 throw new InvalidOperationException("Device or resource busy");
87
88             case BluetoothError.ResourceUnavailable:
89                 throw new InvalidOperationException("Resource temporarily unavailable");
90
91             case BluetoothError.ServiceNotFound:
92                 throw new InvalidOperationException("Service Not Found");
93
94             case BluetoothError.ServiceSearchFailed:
95                 throw new InvalidOperationException("Service search failed");
96
97             default:
98                 throw new InvalidOperationException("Unknown exception");
99             }
100         }
101     }
102 }
103