# Zend expressive authentication catch error

**URL:** <https://discourse.laminas.dev/t/zend-expressive-authentication-catch-error/1200>\
**Category:** Mezzio\
**Tags:** authentication\
**Created:** [September 25, 2019, 4:31am UTC](https://discourse.laminas.dev/t/zend-expressive-authentication-catch-error/1200 "2019-09-25T04:31:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjamingb](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/benjamingb/32/93_2.png) [@benjamingb](https://discourse.laminas.dev/u/benjamingb)\
**Post date:** [September 25, 2019, 4:31am UTC](https://discourse.laminas.dev/t/zend-expressive-authentication-catch-error/1200/1 "2019-09-25T04:31:53Z")

</div>

I am using Zend Expressive to create APIRest

I’m using Htpasswd.

```
      'aliases' => [
                    AuthenticationInterface::class => Basic\BasicAccess::class,
                    UserRepositoryInterface::class => UserRepository\Htpasswd::class
                ]

```

It works correctly and makes the validation,  
But when I pass a wrong user I get an exception  
{  
“exception”: {  
“class”: “ErrorException”,  
“code”: 0,  
“message”: “Undefined offset: 1”,  
“file”: “/var/www/vendor/zendframework/zend-expressive-authentication/src/UserRepository/Htpasswd.php”,  
“line”: 66,  
“trace”: [  
{  
“file”: “/var/www/vendor/zendframework/zend-expressive-authentication/src/UserRepository/Htpasswd.php”,  
“line”: 66,  
“function”: “Zend\ProblemDetails\{closure}”,  
“class”: “Zend\ProblemDetails\ProblemDetailsMiddleware”,  
“type”: “-\>”,  
“args”: [  
8,  
“Undefined offset: 1”,  
“/var/www/vendor/zendframework/zend-expressive-authentication/src/UserRepository/Htpasswd.php”,  
66,  
{  
“credential”: “testx”,  
“password”: “test”,  
“handle”: “Resource id #6 of type stream”,  
“found”: false,  
“line”: “\n”,  
“name”: “\n”,  
“hash”: “$2y$05$…”  
}  
]  
},

How can I capture that exception to send you a message?
