Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

330
Visualizações
PHP cuts off parts of long arguments in exception stack traces. How to tell it not to?

Below is an example of the error message from PHP 7 runtime:

PHP Fatal error: Uncaught Error: Class 'Predis\Connection\ConnectionException' not found in predis.php:4168

Stack trace:

#0 /var/www/api/libraries/predis/predis.php(4455): Predis\Connection\AbstractConnection->onConnectionError('Error while rea...')

Note ellipsis in the first stack trace line line marked #0:

('Error while rea...')

That's where the most important information would have been, had it not been cut off. Other error messages have the same problem, often cutting off very valuable parts of the message.

Is there a setting that we can use to print more information in stack traces? The exact version of PHP we're using is 7.1.1.

Update The exact issue we're having is described in How to disable PHP cutting off parts of long arguments in exception stack trace?. This question can be closed a dupe. The idea is to catch the exception, call Exception::getTrace() and construct the error message manually. The exception can be caught in the global hander, or in each try/catch block. The default implementation of Exception::getTraceAsString truncates long function arguments.

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

If you wrap the calls that might fail in a try { ... } catch (Exception $e) { ... } block, you can display as much of the exception error messages as you wish.

You will also be able to control what you code does with the error, or helping to better avoid the issue in the future.

over 4 years ago · Santiago Trujillo Relatório

0

The error output generated for exception messages is handled by the installed debugger. The default that comes with PHP isn't that informative and you can not customize that output.

You can attach your own error handler and print your own stack traces, or you can change the debugger installed in PHP.

If you install xDebug or Zend debugger you get more information in the stack trace.

https://xdebug.org/docs/stack_trace

enter image description here

over 4 years ago · Santiago Trujillo Relatório

0

You can use getTraceAsString();

<?php
   function test() {
     throw new Exception;
   }

  try {
       test();
  } catch(Exception $e) {
       echo $e->getTraceAsString();
  }
 ?>
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda