Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#constants) \| [Ctors](https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#pubctors) \| [Methods](https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#inhmethods)

# BluetoothSocketException

*** ** * ** ***

` public class BluetoothSocketException `   
` ` ` ` ` ` ` extends https://developer.android.com/reference/java/io/IOException ` ` `

|---|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||||
| ↳ | [java.lang.Throwable](https://developer.android.com/reference/java/lang/Throwable) ||||
|   | ↳ | [java.lang.Exception](https://developer.android.com/reference/java/lang/Exception) |||
|   |   | ↳ | [java.io.IOException](https://developer.android.com/reference/java/io/IOException) ||
|   |   |   | ↳ | android.bluetooth.BluetoothSocketException |

<br />

*** ** * ** ***

Thrown when an error occurs during a Bluetooth Socket related exception.

This is currently intended to be thrown for a failure during `https://developer.android.com/reference/android/bluetooth/BluetoothSocket` operations.

## Summary

| ### Constants ||
|---|---|
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#BLUETOOTH_OFF_FAILURE` Error code returned by `https://developer.android.com/reference/android/bluetooth/BluetoothSocket` during a socket operation that failed because Bluetooth is turned off. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_ACL_FAILURE` Error code during connect when there is an ACL connection failure. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_CLIENT_SECURITY_FAILURE` Error code during connect when security clearance fails on the client during L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHENTICATION` Error code during connect when authentication fails on the peer device during L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHORIZATION` Error code during connect when authorization fails on the peer device during L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPTION` Error code during connect for insufficient encryption from the peer device during L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE` Error code during connect indicating insufficient encryption key size on the peer device during L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INVALID_PARAMETERS` Error code during connect for invalid parameters from the peer device during L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INVALID_SOURCE_CID` Error code during connect for invalid Channel ID from the peer device during L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_NO_PSM_AVAILABLE` Error code during connect when no PSM is available for L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_NO_RESOURCES` Error code during connect when no resources are available for L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_SOURCE_CID_ALREADY_ALLOCATED` Error code during connect for already allocated Channel ID from the peer device during L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_TIMEOUT` Error code during connect when L2CAP connection timeout. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_UNACCEPTABLE_PARAMETERS` Error code during connect for unacceptable Parameters from the peer device during L2CAP connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_UNKNOWN` Error code returned by `https://developer.android.com/reference/android/bluetooth/BluetoothSocket` during a L2CAP-related socket operation that failed for an unknown reason. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#NULL_DEVICE` Error code during connect when null device attempts to do socket connection. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#RPC_FAILURE` Error code during connect when a Runtime RPC exception occurs. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_CLOSED` Error code returned by `https://developer.android.com/reference/android/bluetooth/BluetoothSocket` during a socket operation that failed because the socket has been closed. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_CONNECTION_FAILURE` Error code during connect for generic socket connection failures. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_MANAGER_FAILURE` Error code returned by `https://developer.android.com/reference/android/bluetooth/BluetoothSocket` during a socket operation that failed because socket manager is not available. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#UNIX_FILE_SOCKET_CREATION_FAILURE` Error code during connect when the UNIX socket connection creation fails. |
| `int` | `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#UNSPECIFIED` Error code representing a failure during `https://developer.android.com/reference/android/bluetooth/BluetoothSocket`. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#BluetoothSocketException(int)(int code) ` Create a `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException` with an error code. |
| ` https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#BluetoothSocketException(int,%20java.lang.String)(int code, https://developer.android.com/reference/java/lang/String msg) ` Create a `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException` with an error code and custom error message. |

| ### Public methods ||
|---|---|
| ` int` | ` https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#getErrorCode()() ` Returns the error code associated to this failure. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Throwable ` ` final void` ` https://developer.android.com/reference/java/lang/Throwable#addSuppressed(java.lang.Throwable)(https://developer.android.com/reference/java/lang/Throwable exception) `

Appends the specified exception to the exceptions that were suppressed in order to deliver this exception.
` https://developer.android.com/reference/java/lang/Throwable` ` https://developer.android.com/reference/java/lang/Throwable#fillInStackTrace()() `

Fills in the execution stack trace.
` https://developer.android.com/reference/java/lang/Throwable` ` https://developer.android.com/reference/java/lang/Throwable#getCause()() `

Returns the cause of this throwable or `null` if the cause is nonexistent or unknown.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Throwable#getLocalizedMessage()() `

Creates a localized description of this throwable.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Throwable#getMessage()() `

Returns the detail message string of this throwable.
` https://developer.android.com/reference/java/lang/StackTraceElement` ` https://developer.android.com/reference/java/lang/Throwable#getStackTrace()() `

Provides programmatic access to the stack trace information printed by `https://developer.android.com/reference/java/lang/Throwable#printStackTrace()`.
` final https://developer.android.com/reference/java/lang/Throwable` ` https://developer.android.com/reference/java/lang/Throwable#getSuppressed()() `

Returns an array containing all of the exceptions that were suppressed, typically by the `try`-with-resources statement, in order to deliver this exception.
` https://developer.android.com/reference/java/lang/Throwable` ` https://developer.android.com/reference/java/lang/Throwable#initCause(java.lang.Throwable)(https://developer.android.com/reference/java/lang/Throwable cause) `

Initializes the *cause* of this throwable to the specified value.
` void` ` https://developer.android.com/reference/java/lang/Throwable#printStackTrace()() `

Prints this throwable and its backtrace to the standard error stream.
` void` ` https://developer.android.com/reference/java/lang/Throwable#printStackTrace(java.io.PrintWriter)(https://developer.android.com/reference/java/io/PrintWriter s) `

Prints this throwable and its backtrace to the specified print writer.
` void` ` https://developer.android.com/reference/java/lang/Throwable#printStackTrace(java.io.PrintStream)(https://developer.android.com/reference/java/io/PrintStream s) `

Prints this throwable and its backtrace to the specified print stream.
` void` ` https://developer.android.com/reference/java/lang/Throwable#setStackTrace(java.lang.StackTraceElement[])(https://developer.android.com/reference/java/lang/StackTraceElement stackTrace) `

Sets the stack trace elements that will be returned by `https://developer.android.com/reference/java/lang/Throwable#getStackTrace()` and printed by `https://developer.android.com/reference/java/lang/Throwable#printStackTrace()` and related methods.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Throwable#toString()() `

Returns a short description of this throwable.
From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### BLUETOOTH_OFF_FAILURE

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int BLUETOOTH_OFF_FAILURE
```

Error code returned by `https://developer.android.com/reference/android/bluetooth/BluetoothSocket` during a socket operation that failed because Bluetooth is turned off.

<br />

Constant Value: 15 (0x0000000f)

### L2CAP_ACL_FAILURE

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_ACL_FAILURE
```

Error code during connect when there is an ACL connection failure.

<br />

Constant Value: 2 (0x00000002)

### L2CAP_CLIENT_SECURITY_FAILURE

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_CLIENT_SECURITY_FAILURE
```

Error code during connect when security clearance fails on the client during L2CAP connection.

<br />

Constant Value: 3 (0x00000003)

### L2CAP_INSUFFICIENT_AUTHENTICATION

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_INSUFFICIENT_AUTHENTICATION
```

Error code during connect when authentication fails on the peer device during L2CAP connection.

<br />

Constant Value: 4 (0x00000004)

### L2CAP_INSUFFICIENT_AUTHORIZATION

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_INSUFFICIENT_AUTHORIZATION
```

Error code during connect when authorization fails on the peer device during L2CAP connection.

<br />

Constant Value: 5 (0x00000005)

### L2CAP_INSUFFICIENT_ENCRYPTION

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_INSUFFICIENT_ENCRYPTION
```

Error code during connect for insufficient encryption from the peer device during L2CAP connection.

<br />

Constant Value: 7 (0x00000007)

### L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE
```

Error code during connect indicating insufficient encryption key size on the peer device during L2CAP connection.

<br />

Constant Value: 6 (0x00000006)

### L2CAP_INVALID_PARAMETERS

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_INVALID_PARAMETERS
```

Error code during connect for invalid parameters from the peer device during L2CAP connection.

<br />

Constant Value: 11 (0x0000000b)

### L2CAP_INVALID_SOURCE_CID

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_INVALID_SOURCE_CID
```

Error code during connect for invalid Channel ID from the peer device during L2CAP connection.

<br />

Constant Value: 8 (0x00000008)

### L2CAP_NO_PSM_AVAILABLE

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_NO_PSM_AVAILABLE
```

Error code during connect when no PSM is available for L2CAP connection.

<br />

Constant Value: 13 (0x0000000d)

### L2CAP_NO_RESOURCES

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_NO_RESOURCES
```

Error code during connect when no resources are available for L2CAP connection.

<br />

Constant Value: 12 (0x0000000c)

### L2CAP_SOURCE_CID_ALREADY_ALLOCATED

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_SOURCE_CID_ALREADY_ALLOCATED
```

Error code during connect for already allocated Channel ID from the peer device during L2CAP connection.

<br />

Constant Value: 9 (0x00000009)

### L2CAP_TIMEOUT

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_TIMEOUT
```

Error code during connect when L2CAP connection timeout.

<br />

Constant Value: 14 (0x0000000e)

### L2CAP_UNACCEPTABLE_PARAMETERS

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_UNACCEPTABLE_PARAMETERS
```

Error code during connect for unacceptable Parameters from the peer device during L2CAP connection.

<br />

Constant Value: 10 (0x0000000a)

### L2CAP_UNKNOWN

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int L2CAP_UNKNOWN
```

Error code returned by `https://developer.android.com/reference/android/bluetooth/BluetoothSocket` during a L2CAP-related socket operation that failed for an unknown reason.

<br />

Constant Value: 1 (0x00000001)

### NULL_DEVICE

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int NULL_DEVICE
```

Error code during connect when null device attempts to do socket connection.

<br />

Constant Value: 19 (0x00000013)

### RPC_FAILURE

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RPC_FAILURE
```

Error code during connect when a Runtime RPC exception occurs.

<br />

Constant Value: 20 (0x00000014)

### SOCKET_CLOSED

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SOCKET_CLOSED
```

Error code returned by `https://developer.android.com/reference/android/bluetooth/BluetoothSocket` during a socket operation that failed because the socket has been closed.

<br />

Constant Value: 17 (0x00000011)

### SOCKET_CONNECTION_FAILURE

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SOCKET_CONNECTION_FAILURE
```

Error code during connect for generic socket connection failures.

<br />

Constant Value: 18 (0x00000012)

### SOCKET_MANAGER_FAILURE

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int SOCKET_MANAGER_FAILURE
```

Error code returned by `https://developer.android.com/reference/android/bluetooth/BluetoothSocket` during a socket operation that failed because socket manager is not available.

<br />

Constant Value: 16 (0x00000010)

### UNIX_FILE_SOCKET_CREATION_FAILURE

Added in [API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int UNIX_FILE_SOCKET_CREATION_FAILURE
```

Error code during connect when the UNIX socket connection creation fails.

<br />

Constant Value: 21 (0x00000015)

### UNSPECIFIED

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int UNSPECIFIED
```

Error code representing a failure during `https://developer.android.com/reference/android/bluetooth/BluetoothSocket`. The reason for failure isn't specified.

<br />

Constant Value: 0 (0x00000000)

## Public constructors

### BluetoothSocketException

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public BluetoothSocketException (int code)
```

Create a `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException` with an error code. A generic error message is generated based on the `code` provided.

<br />

| Parameters ||
|---|---|
| `code` | `int`: : error code representing the reason for failure. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#UNSPECIFIED` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_UNKNOWN` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_ACL_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_CLIENT_SECURITY_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHENTICATION` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHORIZATION` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPTION` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INVALID_SOURCE_CID` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_SOURCE_CID_ALREADY_ALLOCATED` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_UNACCEPTABLE_PARAMETERS` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INVALID_PARAMETERS` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_NO_RESOURCES` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_NO_PSM_AVAILABLE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_TIMEOUT` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#BLUETOOTH_OFF_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_MANAGER_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_CLOSED` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_CONNECTION_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#NULL_DEVICE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#RPC_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#UNIX_FILE_SOCKET_CREATION_FAILURE` |

### BluetoothSocketException

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public BluetoothSocketException (int code, 
                String msg)
```

Create a `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException` with an error code and custom error message.

<br />

| Parameters ||
|---|---|
| `code` | `int`: : error code representing the reason for failure. Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#UNSPECIFIED` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_UNKNOWN` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_ACL_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_CLIENT_SECURITY_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHENTICATION` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHORIZATION` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPTION` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INVALID_SOURCE_CID` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_SOURCE_CID_ALREADY_ALLOCATED` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_UNACCEPTABLE_PARAMETERS` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INVALID_PARAMETERS` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_NO_RESOURCES` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_NO_PSM_AVAILABLE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_TIMEOUT` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#BLUETOOTH_OFF_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_MANAGER_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_CLOSED` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_CONNECTION_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#NULL_DEVICE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#RPC_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#UNIX_FILE_SOCKET_CREATION_FAILURE` |
| `msg` | `String`: : Custom error message associated to the failure. This value cannot be `null`. <br /> |

## Public methods

### getErrorCode

Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getErrorCode ()
```

Returns the error code associated to this failure.

<br />

| Returns ||
|---|---|
| `int` | Value is one of the following: - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#UNSPECIFIED` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_UNKNOWN` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_ACL_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_CLIENT_SECURITY_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHENTICATION` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_AUTHORIZATION` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPT_KEY_SIZE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INSUFFICIENT_ENCRYPTION` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INVALID_SOURCE_CID` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_SOURCE_CID_ALREADY_ALLOCATED` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_UNACCEPTABLE_PARAMETERS` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_INVALID_PARAMETERS` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_NO_RESOURCES` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_NO_PSM_AVAILABLE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#L2CAP_TIMEOUT` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#BLUETOOTH_OFF_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_MANAGER_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_CLOSED` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#SOCKET_CONNECTION_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#NULL_DEVICE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#RPC_FAILURE` - `https://developer.android.com/reference/android/bluetooth/BluetoothSocketException#UNIX_FILE_SOCKET_CREATION_FAILURE` |