【问题标题】:Symfony truncated errors annoyingly cut off my error messag (truncated...)Symfony 截断错误烦人地切断了我的错误消息(截断...)
【发布时间】:2018-06-15 11:00:48
【问题描述】:

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

终端

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

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

【问题讨论】:

  • 通过检查日志文件
  • 所以./var/log/dev.log 就是答案。谢谢。

标签: php symfony truncated


【解决方案1】:

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

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

【讨论】:

  • 添加另一个答案./var/log/dev.log,我会接受的。
【解决方案2】:

检查日志文件:

var/log/dev.log

你也可以这样做

tail -f var/log/dev.log

查看日志中写入的内容

【讨论】:

    猜你喜欢
    • 2012-09-12
    • 2016-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 2014-06-22
    • 2023-04-03
    相关资源
    最近更新 更多