# Server Error 500 when trying to implement Error Handler

**URL:** <https://discourse.slimframework.com/t/server-error-500-when-trying-to-implement-error-handler/6169>\
**Category:** Questions\
**Created:** [August 31, 2025, 2:48pm UTC](https://discourse.slimframework.com/t/server-error-500-when-trying-to-implement-error-handler/6169 "2025-08-31T14:48:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pcoloma](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/pcoloma/32/1700_2.png) [@pcoloma](https://discourse.slimframework.com/u/pcoloma)\
**Post date:** [August 31, 2025, 2:48pm UTC](https://discourse.slimframework.com/t/server-error-500-when-trying-to-implement-error-handler/6169/1 "2025-08-31T14:48:48Z")

</div>

Hello, I’m reaching out, some previous experience with Slim 3 moving to 4. I’m trying to implement the code given in the official documentation here: [Application - Slim Framework](https://www.slimframework.com/docs/v4/objects/application.html#advanced-notices-and-warnings-handling)

Stangely I have a 500 Error thrown when accessing the root of the website, (I did create a basic Hello World route for / that worked fine before I’ve set up the 2 given classes)

Looking at the psr7 version it is the 1.7  
Here is the full error message  
{ “statusCode”: 500, “error”: { “type”: “SERVER\_ERROR”, “description”: “{closure}(): Argument #1 ($request) must be of type Request, Slim\\Psr7\\Request given, called in \/Users\/patrice\/Documents\/www\/www-idapremsel\/vendor\/slim\/slim\/Slim\/Handlers\/Strategies\/RequestResponse.php on line 39” } }

I must add that if I type /gibberishxxxx I get a 404 so something is working 😉

Any ideas? Thanks!!!

---

<div class="post-metadata">

**Author:** ![SpdyMx](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@SpdyMx](https://discourse.slimframework.com/u/SpdyMx)\
**Post date:** [September 1, 2025, 7:26pm UTC](https://discourse.slimframework.com/t/server-error-500-when-trying-to-implement-error-handler/6169/2 "2025-09-01T19:26:05Z")

</div>

If I am right the psr7 Request type is not the one given to your closure.

Try adding this

use Psr\Http\Message\ServerRequestInterface as Request;

---

<div class="post-metadata">

**Author:** ![pcoloma](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/pcoloma/32/1700_2.png) [@pcoloma](https://discourse.slimframework.com/u/pcoloma)\
**Post date:** [September 1, 2025, 7:55pm UTC](https://discourse.slimframework.com/t/server-error-500-when-trying-to-implement-error-handler/6169/3 "2025-09-01T19:55:27Z")

</div>

Nice hint!!! I added your code and still the same… But the culprit was not the Request object but the response… So adding

use Psr\Http\Message\ResponseInterface as Response;

Solved the issue!!! Hello World!.. Thanks!! Is this bit missing from the official documentation example? Or my wrong doing copying pasting…

---

<div class="post-metadata">

**Author:** ![SpdyMx](https://avatars.discourse-cdn.com/v4/letter/s/dec6dc/32.png) [@SpdyMx](https://discourse.slimframework.com/u/SpdyMx)\
**Post date:** [September 2, 2025, 4:37am UTC](https://discourse.slimframework.com/t/server-error-500-when-trying-to-implement-error-handler/6169/4 "2025-09-02T04:37:44Z")

</div>

Great news.

I am using slim/slim-skeleton as a base of my projects and composer. The base exemple showed me those 2 lines (Request and Response).

Habe fun

---

<div class="post-metadata">

**Author:** ![pcoloma](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/pcoloma/32/1700_2.png) [@pcoloma](https://discourse.slimframework.com/u/pcoloma)\
**Post date:** [September 2, 2025, 2:39pm UTC](https://discourse.slimframework.com/t/server-error-500-when-trying-to-implement-error-handler/6169/5 "2025-09-02T14:39:13Z")

</div>

Great idea I will start from there.

All the best
