> For the complete documentation index, see [llms.txt](https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinesis-school-of-programming.gitbook.io/nestjs-unleashed/extra-module-2-exception-filters/database-exception-filter/last-steps.md).

# Last steps

The conclusion of this exception filter.

We have everything we need. Back in the <mark style="color:blue;">`catch()`</mark> method, let's define an <mark style="color:blue;">`httpError`</mark> and a <mark style="color:blue;">`description`</mark> using the recently created method. If the <mark style="color:blue;">`httpError`</mark> is <mark style="color:blue;">undefined</mark>, activate the <mark style="color:blue;">`BaseExceptionFilter`</mark>.

```typescript
const { httpError, description } = this.createErrorData(code, detail);

if (!httpError) {
  return super.catch(exception, host);
}
```

Then, we should obtain the fields from the <mark style="color:blue;">`httpError`</mark>, and the <mark style="color:blue;">`name`</mark> and <mark style="color:blue;">`value`</mark> of the field that caused the error.

```typescript
const { status, error } = httpError;
const { fieldName, fieldValue } = this.extractMessageData(detail);
```

Finally, create a <mark style="color:blue;">`meta`</mark> field to hold all the extra information which may help better understand the exception.

```typescript
const meta = { description, fieldName, fieldValue, table };
```

The last step is to set up the <mark style="color:blue;">`response`</mark> and enable this filter globally, and we're done!

```typescript
response.status(status).json({
  statusCode: status,
  message: detail,
  error,
  meta,
});
```

<mark style="color:green;">**Commit**</mark> - Creating the database exception filter
