# Error handling for DQL query client

**URL:** <https://community.dynatrace.com/t/error-handling-for-dql-query-client/39052>\
**Category:** Developer Q&A Forum\
**Tags:** coding-assistance\
**Created:** [March 28, 2023, 12:53pm UTC](https://community.dynatrace.com/t/error-handling-for-dql-query-client/39052 "2023-03-28T12:53:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![s\_eilmsteiner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/s_eilmsteiner/32/32799_2.png) [@s\_eilmsteiner](https://community.dynatrace.com/u/s_eilmsteiner)\
**Post date:** [March 28, 2023, 12:53pm UTC](https://community.dynatrace.com/t/error-handling-for-dql-query-client/39052/1 "2023-03-28T12:53:08Z")

</div>

Hi,  
I fetch data via DQL using the&nbsp;queryExecutionClient from&nbsp;@dynatrace-sdk/client-query and I want to handle errors correctly. I know that there is the ErrorResponseDetails, but I don’t know how to extract it.

```javascript
import {
  ErrorResponseDetails,
  queryExecutionClient,
  QueryResult,
} from '@dynatrace-sdk/client-query';

...

queryExecutionClient
        .queryExecute({
          body: {
            query,
            requestTimeoutMilliseconds: 30000,
          },
          abortSignal,
        })
        .then((response) => {
          setResult(response.result);
          setError(undefined);
        })
        .catch((error) => {
          // How can I get the ErrorResponseDetails
        })
        .finally(() => {
          setLoading(false);
        });

```

---

<div class="post-metadata">

**Author:** ![michal\_zawislak](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/michal_zawislak/32/13613_2.png) [@michal\_zawislak](https://community.dynatrace.com/u/michal_zawislak)\
**Post date:** [March 28, 2023, 1:02pm UTC](https://community.dynatrace.com/t/error-handling-for-dql-query-client/39052/2 "2023-03-28T13:02:00Z")

</div>

Hi s\_eilmsteiner,

You could try using the util function “isClientRequestError” with the desired type of error or “isErrorEnvelopeError”. It depends on the expected error.

```auto
import { queryExecutionClient, ErrorResponseDetails, isClientRequestError, isErrorEnvelopeError } from '@dynatrace-sdk/client-query';

await queryExecutionClient.queryExecute({ ... }).catch((e) => {
  if (isClientRequestError<ErrorResponseDetails>(e)) {
    console.error('ErrorResponseDetails', e);
  }
  // OR
  if (isErrorEnvelopeError(e)) {
    console.error('EnvelopeError', e);
  }
});

```
