0

I am using GuzzleHttp to send post request to another project. But when I have error I can't see all error it is always truncated.

Can anyone know how to remove the (truncated...) so that I can fully see the error?

GuzzleHttp\Exception\ServerException Server error: POST http://127.0.0.1:8000/api/api resulted in a 500 Internal Server Error response: <!doctype html> <!-- TypeError: Argument 1 passed to Illuminate\Database\Query\Builder::inser (truncated...)

X.Jop
  • 13
  • 1
  • Full error should be available in `storage/laravel.log` file in the project folder. – Muhammad Tashfeen Dec 13 '22 at 08:25
  • You can try setting the `Accept: application/json` header in your request to (hopefully) get the other project to return a JSON error response which gets to the actual error with less filler – apokryfos Dec 13 '22 at 08:29

1 Answers1

0

The error is only truncated in the Guzzle Exception message. You find the error in full in the other projects' PHP error log if you enable error logging there -- and -- in the response body.

Right now you've enabled display errors (or you're displaying errors in some variant that inserts the message into a HTML comment), check error logging is enabled and locate the appropriate log file.

Alternatively you can configure Guzzle to not throw on "HTTP errors"[1], verify the response status is 500 and if so have the non-truncated information in the response body.

The truncation is only for convenience as exception messages often end up in some line of their own in the PHP error log (of the applications that don't catch it) and such lines have a common limit of 1024 bytes for portability reasons.

Most details of the error situation can only be available within the system (here: the HTTP server you send requests to) and if you want to obtain the least filtered information, always go towards the source. Don't look for things, just obtain them.


  1. c.f. Catching exceptions from Guzzle for the version of the Guzzle API you have in use.
hakre
  • 193,403
  • 52
  • 435
  • 836
  • 1
    Thank you. I found the full log on the other project's laravel.log – X.Jop Dec 13 '22 at 08:43
  • @X.Jop: Yes, always go to the source, the best info can only be there. The 500 internal server error is only given to you to notify you there was a (harsh) problem and the truncated message is only for convenience so you can have a better first-idea what it is about. It can never give you the full picture (in production you likely won't see this info at all even, just getting 500 internal server error and that's it). – hakre Dec 13 '22 at 08:47