Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

329
Views
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.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

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.

about 4 years ago · Santiago Trujillo Report

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

about 4 years ago · Santiago Trujillo Report

0

You can use getTraceAsString();

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

  try {
       test();
  } catch(Exception $e) {
       echo $e->getTraceAsString();
  }
 ?>
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!