Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Improving exception messaging for PDO using errorInfo() #5696

Merged
merged 1 commit into from

2 participants

@DragonBe

Sometimes it's really annoying receiving a simple, totally not meaningful exception message like "Statement could not be executed" as there can be tons of reasons why it could not be executed.

As I've spent too much time trying to figure out what was wrong I modified this file with current change and fixed the issue immediately.

So to help fellow developers in their development I would like to offer this improvement.

Michelangelo

@ralphschindler ralphschindler merged commit 456864d into zendframework:master

1 check passed

Details default The Travis CI build passed
@ralphschindler ralphschindler referenced this pull request from a commit
@ralphschindler ralphschindler Forward #5696 to develop
Merge branch 'DragonBe-pdostmt-improvement' into develop

* DragonBe-pdostmt-improvement:
  Fixed formatting of Zend\Db PDO's Statement object's errorInfo handling
  Improving exception messaging for PDO using errorInfo() (see http://www.php.net/manual/en/pdo.errorinfo.php for details)
126381d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  library/Zend/Db/Adapter/Driver/Pdo/Statement.php
View
3  library/Zend/Db/Adapter/Driver/Pdo/Statement.php
@@ -242,7 +242,8 @@ public function execute($parameters = null)
if ($this->profiler) {
$this->profiler->profilerFinish();
}
- throw new Exception\InvalidQueryException('Statement could not be executed', null, $e);
+ throw new Exception\InvalidQueryException(
+ 'Statement could not be executed (' . implode(' - ', $this->resource->errorInfo()) . ')', null, $e);
}
if ($this->profiler) {
Something went wrong with that request. Please try again.