[Bluetooth] Add BluetoothHidDevice APIs (#574)
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Bluetooth / Tizen.Network.Bluetooth / BluetoothError.cs
index 83ce73d..3f245d9 100644 (file)
@@ -27,82 +27,90 @@ namespace Tizen.Network.Bluetooth
         /// Exceptions for Bluetooth Errors.
         /// </summary>
         /// <exception cref="InvalidOperationException">Thrown when the Bluetooth Error happens.</exception>
-        static internal void ThrowBluetoothException(int exception)
+        internal static void ThrowBluetoothException(int exception)
+        {
+            throw CreateBluetoothException(exception);
+        }
+
+        /// <summary>
+        /// Creates Bluetooth Exception.
+        /// </summary>
+        internal static Exception CreateBluetoothException(int exception)
         {
             BluetoothError error = (BluetoothError)exception;
             switch (error)
             {
-            case BluetoothError.InvalidParameter:
-                throw new InvalidOperationException("Invalid parameter");
+                case BluetoothError.InvalidParameter:
+                    return new InvalidOperationException("Invalid parameter");
 
-            case BluetoothError.Cancelled:
-                throw new InvalidOperationException("Operation cancelled");
+                case BluetoothError.Cancelled:
+                    return new InvalidOperationException("Operation cancelled");
 
-            case BluetoothError.AlreadyDone:
-                throw new InvalidOperationException("Operation already done");
+                case BluetoothError.AlreadyDone:
+                    return new InvalidOperationException("Operation already done");
 
-            case BluetoothError.TimedOut:
-                throw new InvalidOperationException("Timeout error");
+                case BluetoothError.TimedOut:
+                    return new InvalidOperationException("Timeout error");
 
-            case BluetoothError.AuthFailed:
-                throw new InvalidOperationException("Authentication failed");
+                case BluetoothError.AuthFailed:
+                    return new InvalidOperationException("Authentication failed");
 
-            case BluetoothError.AuthRejected:
-                throw new InvalidOperationException("Authentication rejected");
+                case BluetoothError.AuthRejected:
+                    return new InvalidOperationException("Authentication rejected");
 
-            case BluetoothError.NoData:
-                throw new InvalidOperationException("No data available");
+                case BluetoothError.NoData:
+                    return new InvalidOperationException("No data available");
 
-            case BluetoothError.NotEnabled:
-                throw new InvalidOperationException("Local adapter not enabled");
+                case BluetoothError.NotEnabled:
+                    return new InvalidOperationException("Local adapter not enabled");
 
-            case BluetoothError.NotInitialized:
-                throw new InvalidOperationException("Local adapter not initialized");
+                case BluetoothError.NotInitialized:
+                    return new InvalidOperationException("Local adapter not initialized");
 
-            case BluetoothError.NowInProgress:
-                throw new InvalidOperationException("Operation now in progress");
+                case BluetoothError.NowInProgress:
+                    return new InvalidOperationException("Operation now in progress");
 
-            case BluetoothError.NotInProgress:
-                throw new InvalidOperationException("Operation not in progress");
+                case BluetoothError.NotInProgress:
+                    return new InvalidOperationException("Operation not in progress");
 
-            case BluetoothError.NotSupported:
-                throw new NotSupportedException("Bluetooth is not supported");
+                case BluetoothError.NotSupported:
+                    return new NotSupportedException("Bluetooth is not supported");
 
-            case BluetoothError.OperationFailed:
-                throw new InvalidOperationException("Operation failed");
+                case BluetoothError.OperationFailed:
+                    return new InvalidOperationException("Operation failed");
 
-            case BluetoothError.OutOfMemory:
-                throw new InvalidOperationException("Out of memory");
+                case BluetoothError.OutOfMemory:
+                    return new InvalidOperationException("Out of memory");
 
-            case BluetoothError.PermissionDenied:
-                throw new InvalidOperationException("Permission denied");
+                case BluetoothError.PermissionDenied:
+                    return new InvalidOperationException("Permission denied");
 
-            case BluetoothError.QuotaExceeded:
-                throw new InvalidOperationException("Quota exceeded");
+                case BluetoothError.QuotaExceeded:
+                    return new InvalidOperationException("Quota exceeded");
 
-            case BluetoothError.RemoteDeviceNotBonded:
-                throw new InvalidOperationException("Remote device not bonded");
+                case BluetoothError.RemoteDeviceNotBonded:
+                    return new InvalidOperationException("Remote device not bonded");
 
-            case BluetoothError.RemoteDeviceNotConnected:
-                throw new InvalidOperationException("Remote device not connected");
+                case BluetoothError.RemoteDeviceNotConnected:
+                    return new InvalidOperationException("Remote device not connected");
 
-            case BluetoothError.RemoteDeviceNotFound:
-                throw new InvalidOperationException("Remote device not found");
+                case BluetoothError.RemoteDeviceNotFound:
+                    return new InvalidOperationException("Remote device not found");
 
-            case BluetoothError.ResourceBusy:
-                throw new InvalidOperationException("Device or resource busy");
+                case BluetoothError.ResourceBusy:
+                    return new InvalidOperationException("Device or resource busy");
 
-            case BluetoothError.ResourceUnavailable:
-                throw new InvalidOperationException("Resource temporarily unavailable");
+                case BluetoothError.ResourceUnavailable:
+                    return new InvalidOperationException("Resource temporarily unavailable");
 
-            case BluetoothError.ServiceNotFound:
-                throw new InvalidOperationException("Service Not Found");
+                case BluetoothError.ServiceNotFound:
+                    return new InvalidOperationException("Service Not Found");
 
-            case BluetoothError.ServiceSearchFailed:
-                throw new InvalidOperationException("Service search failed");
+                case BluetoothError.ServiceSearchFailed:
+                    return new InvalidOperationException("Service search failed");
 
-            default:
-                throw new InvalidOperationException("Unknown exception");
+                default:
+                    return new InvalidOperationException("Unknown exception");
             }
         }
     }