Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Undefined array key" for ex handler config lacking i.e. api_code entry. #226

Open
MarcinOrlowski opened this issue Feb 23, 2022 · 3 comments

Comments

@MarcinOrlowski
Copy link
Owner

I have checked this

/** @var \Symfony\Component\HttpKernel\Exception\HttpException $ex */
$http_code = $ex->getStatusCode();

And $ex->getStatusCode() indeed returns 404, but at the same time, the final output has 500 status code.
Here, I just opened a non-existent route:
image

I tried to implement your solution:

  \Symfony\Component\HttpKernel\Exception\HttpException::class => [
      'handler' => \MarcinOrlowski\ResponseBuilder\ExceptionHandlers\HttpExceptionHandler::class,
      'pri' => -100,
      'config' => [
          Symfony\Component\HttpFoundation\Response::HTTP_NOT_FOUND => [
              'http_code' => Symfony\Component\HttpFoundation\Response::HTTP_NOT_FOUND,
          ],

And after that, I receive this error whenever I try to access a wrong route:

{"success":false,"code":113,"locale":"en","message":"Undefined array key \u0022api_code\u0022","data":null,"debug":{"trace":{"class":"ErrorException","file":"\/var\/www\/api\/vendor\/marcin-orlowski\/laravel-api-response-builder\/src\/ExceptionHandlerHelper.php","line":104}}}

Originally posted by @beeyev in #225 (reply in thread)

@beeyev
Copy link

beeyev commented Feb 26, 2022

Well, it seems, that this problem is a bit bigger.
If I try to access a post route as get, it should return 405 code, but instead, it returns 500

@beeyev
Copy link

beeyev commented Mar 26, 2022

Any news?

@MarcinOrlowski
Copy link
Owner Author

Unfortunately I haven't had time to take a look at this. Let me try over forthcoming weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants