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

时间:2018-06-15 11:00:49

标签: php symfony truncated

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

终端

$ 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());
}
...

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

2 个答案:

答案 0 :(得分:2)

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

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

答案 1 :(得分:1)

检查日志文件:

var/log/dev.log

您也可以执行类似

的操作
tail -f var/log/dev.log

了解日志中写的内容