Laminas-db sqlsrv exceptions, how to read error text

My app uses laminas-db and SQL Server. When there’s a SQL error condition, this code in src\Adapter\Driver\Sqlsrv\Connection handles it:

        // if the returnValue is something other than a Sqlsrv_result, bypass wrapping it
        if ($returnValue === false) {
            $errors = sqlsrv_errors();
            // ignore general warnings
            if ($errors[0]['SQLSTATE'] !== '01000') {
                throw new Exception\RuntimeException(
                    'An exception occurred while trying to execute the provided $sql',
                    new ErrorException($errors)

As you can see, it doesn’t retrieve $errors[N][‘message’] and concatenate anything to the exception’s message, but it does take the entire array from sqlsrv_errors(), and pass it to the constructor of src\Adapter\Driver\Sqlsrv\Exception\ErrorException, and use that as the “previous” in the thrown exception. However, all ErrorException does with that argument is store it to a member array, which is great - but it’s protected, and doesn’t appear to implement any way to read it.


namespace Laminas\Db\Adapter\Driver\Sqlsrv\Exception;

use Laminas\Db\Adapter\Exception;

use function sqlsrv_errors;

class ErrorException extends Exception\ErrorException implements ExceptionInterface
     * Errors
     * @var array
    protected $errors = [];

     * Construct
     * @param  bool $errors
    public function __construct($errors = false)
        $this->errors = $errors === false ? sqlsrv_errors() : $errors;

Debugging confirms the SQL errors don’t end up in the Exception message, or in the trace, they seem to only be sealed in this protected array.

So the problem ultimately here is that my app logs the same useless message “An exception occurred while trying to execute the provided $sql” without the actual sqlsrv error messages.

While it would be easy enough to patch laminas-db, I feel it’s more likely I am just missing something. What is the intended way for applications to access the error messages from RDBMS?

Thank you!