# Error hook

The error hook lets you intercept the error returned by your handler, the validation hook, the render hook, and any error during each internal process of KCD.&#x20;

His role is to return a well-formatted error to the client, based on the error provided.

An error hook must have this signature:

```go
type ErrorHook func(w http.ResponseWriter, r *http.Request, err error, logger kcd.LogHook)
```

{% hint style="info" %}
Check out the default [ErrorHook implementation here](https://github.com/alexisvisco/kcd/blob/master/pkg/hook/error.go).

Check out the signature of the [ErrorHook](https://github.com/expectedsh/kcd/blob/master/pkg/hook/hooks.go#L12).
{% endhint %}
