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