Symfony 截断错误烦人地切断了我的错误消息(截断...)

Symfony truncated errors annoyingly cut off my error messag (truncated...)

虽然我遇到的错误本身也是一个问题,但我当前的特殊问题是我什至无法读取错误的一半,因为它被截断了, 所以我不知道错误实际上是什么 is.

终端机

$ vendor/bin/behat features/album.feature
Feature: Provide a consistent standard JSON API endpoint

In order to build interchangeable front ends
  As a JSON API developer
  I need to allow Create, Read, Update, and Delete functionality

  Background:                                          # features\album.feature:7
    Given there are Albums with the following details: # FeatureContext::thereAreAlbumsWithTheFollowingDetails()
      | title                     | track_count | release_date              |
      | The Dark side of the Moon | 12          | 1973-03-24T00:00:00+00:00 |
      | Back in Black             | 9           | 1980-06-25T23:22:21+00:00 |
      | Thriller                  | 23          | 1982-11-30T11:10:09+00:00 |
      Server error: `POST http://127.0.0.1:8000/api/album` resulted in a `500 Internal Server Error` response:
      {
          "code": 500,
          "message": "Unexpected error occured: An exception occurred while executing 'INSERT INTO Album (t (truncated...)
       (GuzzleHttp\Exception\ServerException)

这个错误显然是由我的异常控制器给出的。

ExceptionController.php

...
/**
 * @Rest\View()
 * @param Request $request
 * @param $exception
 * @param DebuggerLoggerInterface|null $logger
 * @return View
 */
public function show(Request $request, $exception, DebugLoggerInterface $logger = null){
    if ($exception instanceof ValidationException) {
        return $this->getView($exception->getStatusCode(), json_decode($exception->getMessage(), true));
    }

    if ($exception instanceof HttpException) {
        return $this->getView($exception->getStatusCode(), $exception->getMessage());
    }

    return $this->getView(null, 'Unexpected error occured: '.$exception->getMessage());
}
...

如何丢失截断并查看完整错误?

你可以去 vendor\guzzlehttp\guzzle\src\Exception\RequestException.php 第 139 行。

并更改此行:$summary = $body->read(120); 您应该能够读取超过 120 个字节并更好地了解您遇到的错误。 (仅用于调试)

检查日志文件:

var/log/dev.log

你也可以这样做

tail -f var/log/dev.log

查看日志中写入的内容