tempest-framework icon indicating copy to clipboard operation
tempest-framework copied to clipboard

feat(router): support giving back json when a request fail

Open NeoIsRecursive opened this issue 3 months ago • 2 comments

Fixes #1619

Okay, so this is very wip, but I wanted to get it out to see if I'm thinking about this correctly before doing more work on this 🙂

The error "shape" is taken from Laravel, which I think it is pretty easy to work with: invalid & generic.

But it should probably be discussed how it should look (maybe problem details or some other easier "standard").

EDIT:

Another thing im thinking about is this:

if ($response->status->isServerError() || $response->status->isClientError()) {
    throw new HttpRequestFailed(
        request: $request,
        status: $response->status,
        cause: $response,
    );
}

Maybe the errors that are handled by the middleware (in forward) shouldn't be cast to HttpRequestFailed? ConvertsToResponse, ValidationFailed and RouteBindingFailed.

NeoIsRecursive avatar Oct 08 '25 20:10 NeoIsRecursive

Wanted to check up: what needs to be done for this one, and can I help? Just want to make sure we don't loose track: it's a good feature and I'd like to see it merged 👍

brendt avatar Nov 08 '25 06:11 brendt

Wanted to check up: what needs to be done for this one, and can I help? Just want to make sure we don't loose track: it's a good feature and I'd like to see it merged 👍

Hi, I haven't had a lot of time (nor energy tbh) the last few weeks, but I do have some stuff locally that I'll clean up and push up asap :)

Whats left:

  • Tests for the "exceptionRenderers"
  • Router tests
  • Make sure that the accepts guard has all the correct html content types

And I did try to remove the throwHttpExceptions thinggy but it triggered a lot of other components to fail so I'll leave that to someone else 😅

NeoIsRecursive avatar Nov 08 '25 11:11 NeoIsRecursive

This pull request is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Dec 09 '25 02:12 github-actions[bot]

This pull request was closed because it has been inactive for 1 day since being marked as stale.

github-actions[bot] avatar Dec 10 '25 02:12 github-actions[bot]

Let's close for now since the PR seems inactive. Happy to revive it when there's time :)

brendt avatar Dec 12 '25 07:12 brendt

I might take a look at this at the same time I take a look at https://github.com/tempestphp/tempest-framework/issues/1805

innocenzi avatar Dec 12 '25 14:12 innocenzi

I might take a look at this at the same time I take a look at https://github.com/tempestphp/tempest-framework/issues/1805

That would be great! I have unfortunatly not had the time to work more on this.

Though ive been thinking about it and Im wondering if doing it like dotnet does might be nice? (register a exception handler, if it returns false, try the next, until the default one is ran)

NeoIsRecursive avatar Dec 13 '25 00:12 NeoIsRecursive