# GetLastAPIError Method - neoVI API

This method returns the error generated by the last API call.

{% tabs %}
{% tab title="C/C++ Declare" %}

```cpp
int _stdcall icsneoGetLastAPIError(void * hObject, int *piErrorNumber);
```

{% endtab %}

{% tab title="Visual Basic .NET Declare" %}

```vbnet
Public Declare Function icsneoGetLastAPIError Lib “icsneo40.dll” (ByVal hObject As IntPtr, ByRef piErrorNumber As Integer) As Integer
```

{% endtab %}

{% tab title="C# Declare" %}

```csharp
[DllImport(“icsneo40.dll”)] public static extern int icsneoGetLastAPIError(IntPtr hObject, ref int piErrorNumber);
```

{% endtab %}
{% endtabs %}

**Parameters**

hObject

\[in] Specifies the driver object created by [OpenNeoDevice](https://docs.intrepidcs.com/neovi-api/win32-api-overview-intrepidcs-api/basic-functions-overview-intrepidcs-api/openneodevice-method-intrepidcs-api).

piErrorNumber

\[out] The value of the error generated by the previous API call will be returned. The text description of the error can then be obtained by calling [GetErrorInfo](https://docs.intrepidcs.com/neovi-api/win32-api-overview-intrepidcs-api/error-functions-overview-intrepidcs-api/geterrorinfo-method-intrepidcs-api).

**Return Values**

If an error was generated and stored during the last API call then 1 will be returned. 0 will be returned if no error was generated since the port was opened or the last time that [GetLastAPIError](https://docs.intrepidcs.com/neovi-api/win32-api-overview-intrepidcs-api/error-functions-overview-intrepidcs-api/getlastapierror-method-intrepidcs-api) was called. The stored error will be cleared after this call. API errors are generated and stored on a ‘per-thread’ basis. The calling thread will only receive errors generated within it’s own context. If a new API error is generated before the previous error has been retrieved, the previous error will be lost. All errors generated can still be retrieved using [GetErrorMessages](https://docs.intrepidcs.com/neovi-api/win32-api-overview-intrepidcs-api/error-functions-overview-intrepidcs-api/geterrormessages-method-intrepidcs-api). However, [GetErrorMessages](https://docs.intrepidcs.com/neovi-api/win32-api-overview-intrepidcs-api/error-functions-overview-intrepidcs-api/geterrormessages-method-intrepidcs-api) will return errors generated in all threads, not just the current thread.

**Remarks**

### Examples

{% tabs %}
{% tab title="C/C++ Example:" %}

```
```

{% endtab %}

{% tab title="C# Example:" %}

```
```

{% endtab %}

{% tab title="Visual Basic .NET Example:" %}

```
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.intrepidcs.com/neovi-api/win32-api-overview-intrepidcs-api/error-functions-overview-intrepidcs-api/getlastapierror-method-intrepidcs-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
