Merge pull request #24598 from nextcloud/techdebt/noid/wrap-the-exception-to-make-debuggin-easier

Make debugging migration exceptions easier
This commit is contained in:
Joas Schilling 2020-12-08 17:10:20 +01:00 committed by GitHub
commit 13a1eb6494
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -27,6 +27,7 @@
namespace OC\DB;
use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\Index;
@ -421,7 +422,13 @@ class MigrationService {
// read known migrations
$toBeExecuted = $this->getMigrationsToExecute($to);
foreach ($toBeExecuted as $version) {
$this->executeStep($version, $schemaOnly);
try {
$this->executeStep($version, $schemaOnly);
} catch (DriverException $e) {
// The exception itself does not contain the name of the migration,
// so we wrap it here, to make debugging easier.
throw new \Exception('Database error when running migration ' . $to . ' for app ' . $this->getApp(), 0, $e);
}
}
}