> This page is for TWS API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://ibkrcampus.com/docs/llms.txt.

# Receiving Error Messages

## Introduction

When a client application sends a message to TWS which requires a response which has an expected response (i.e. placing an order, requesting market data, subscribing to account updates, etc.), TWS will almost either always

1. Respond with the relevant data or
2. Send an error message to [EWrapper.error()](/docs/tws-api/doc/error/messages).

Error messages sent by the TWS are handled by the [EWrapper.error()](/docs/tws-api/doc/error/messages) method. The [EWrapper.error()](/docs/tws-api/doc/error/messages) event contains the originating request Id (or the orderId in case the error was raised when placing an order), a numeric error code and a brief description. It is important to keep in mind that this function is used for *true* error messages as well as notifications that do not mean anything is wrong.

> **Non-English API Error Messages**
>
> Error messages are sent using Latin1 encoding. Non-Latin error messages are UTF-8 encoded.

#### Receiving Error Messages

`EWrapper.error(reqId, errorTime, errorCode, errorMsg, advancedOrderRejectJson)`

**`reqId`** `integer` — required

The request identifier corresponding to the most recent reqId that maintained the error stream.\
This does not pertain to the orderId from placeOrder, but whatever the most recent requestId is.

---

**`errorTime`** `integer` — required

The Unix timestamp of when the error took place.

---

**`errorCode`** `integer` — required

The Unix timestamp of when the error took place.

---

**`errorMsg`** `string` — required

The Unix timestamp of when the error took place.

---

**`advancedOrderRejectJson`** `string`

The Unix timestamp of when the error took place.

---

\


#### Python

```python
def error(self, reqId: TickerId, errorTime: int, errorCode: int, errorString: str, advancedOrderRejectJson = ""):
  print("Error. Id:", reqId, errorTime, "Code:", errorCode, "Msg:", errorString, "AdvancedOrderRejectJson:", advancedOrderRejectJson)
```

#### Java

```java
@Override
public void error(int id, long errorTime, int errorCode, String errorMsg, String advancedOrderRejectJson) {
  String str = "Error. Id: " + id + ", Code: " + errorCode + ", Msg: " + errorMsg;
  if (advancedOrderRejectJson != null) {
    str += (", AdvancedOrderRejectJson: " + advancedOrderRejectJson);
  }
  System.out.println(str + "\n");
}
```

#### C++

```cpp
void TestCppClient::error(int id, time_t errorTime, int errorCode, const std::string& errorString, const std::string& advancedOrderRejectJson)
{
    printf("Error. Id: %d, Timestamp: %d, Code: %d, Msg: %s, AdvancedOrderRejectJson: %s\n", id, errorTime, errorCode, errorString.c_str(), advancedOrderRejectJson.c_str());
}
```

#### C\#

```csharp
public virtual void error(int id, long errorTime, int errorCode, string errorMsg, string advancedOrderRejectJson)
{
  Console.WriteLine("Error. Id: " + id + "Timestamp: " + errorTime + ", Code: " + errorCode + ", Msg: " + errorMsg + ", AdvancedOrderRejectJson: " + advancedOrderRejectJson + "\n");
}
```

#### VB.NET

```vbnet
Public Sub [error](id As Integer, errorCode As Integer, errorMsg As String, advancedOrderRejectJson As String) Implements IBApi.EWrapper.error
            Console.WriteLine("Error - Id [" & id & "] ErrorCode [" & errorCode & "] ErrorMsg [" & errorMsg & "] AdvancedOrderRejectJson [" & advancedOrderRejectJson & "]")
End Sub
```