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.
19 namespace Tizen.Network.Bluetooth
22 /// A class which is used to Throw the Bluetooth Error exceptions.
24 static internal class BluetoothErrorFactory
27 /// Exceptions for Bluetooth Errors.
29 /// <exception cref="InvalidOperationException">Thrown when the Bluetooth Error happens.</exception>
30 internal static void ThrowBluetoothException(int exception)
32 throw CreateBluetoothException(exception);
36 /// Creates Bluetooth Exception.
38 internal static Exception CreateBluetoothException(int exception)
40 BluetoothError error = (BluetoothError)exception;
43 case BluetoothError.InvalidParameter:
44 return new InvalidOperationException("Invalid parameter");
46 case BluetoothError.Cancelled:
47 return new InvalidOperationException("Operation cancelled");
49 case BluetoothError.AlreadyDone:
50 return new InvalidOperationException("Operation already done");
52 case BluetoothError.TimedOut:
53 return new InvalidOperationException("Timeout error");
55 case BluetoothError.AuthFailed:
56 return new InvalidOperationException("Authentication failed");
58 case BluetoothError.AuthRejected:
59 return new InvalidOperationException("Authentication rejected");
61 case BluetoothError.NoData:
62 return new InvalidOperationException("No data available");
64 case BluetoothError.NotEnabled:
65 return new InvalidOperationException("Local adapter not enabled");
67 case BluetoothError.NotInitialized:
68 return new InvalidOperationException("Local adapter not initialized");
70 case BluetoothError.NowInProgress:
71 return new InvalidOperationException("Operation now in progress");
73 case BluetoothError.NotInProgress:
74 return new InvalidOperationException("Operation not in progress");
76 case BluetoothError.NotSupported:
77 return new NotSupportedException("Bluetooth is not supported");
79 case BluetoothError.OperationFailed:
80 return new InvalidOperationException("Operation failed");
82 case BluetoothError.OutOfMemory:
83 return new InvalidOperationException("Out of memory");
85 case BluetoothError.PermissionDenied:
86 return new InvalidOperationException("Permission denied");
88 case BluetoothError.QuotaExceeded:
89 return new InvalidOperationException("Quota exceeded");
91 case BluetoothError.RemoteDeviceNotBonded:
92 return new InvalidOperationException("Remote device not bonded");
94 case BluetoothError.RemoteDeviceNotConnected:
95 return new InvalidOperationException("Remote device not connected");
97 case BluetoothError.RemoteDeviceNotFound:
98 return new InvalidOperationException("Remote device not found");
100 case BluetoothError.ResourceBusy:
101 return new InvalidOperationException("Device or resource busy");
103 case BluetoothError.ResourceUnavailable:
104 return new InvalidOperationException("Resource temporarily unavailable");
106 case BluetoothError.ServiceNotFound:
107 return new InvalidOperationException("Service Not Found");
109 case BluetoothError.ServiceSearchFailed:
110 return new InvalidOperationException("Service search failed");
113 return new InvalidOperationException("Unknown exception");