Commit 44c07e9b authored by catch's avatar catch

Issue #1545068 by Berdir: Convert Exception in update.inc to PSR-0.

parent c01dafd6
......@@ -321,9 +321,11 @@ function update_module_enable(array $modules) {
* will be displayed at all.
*
* If it fails for whatever reason, it should throw an instance of
* DrupalUpdateException with an appropriate error message, for example:
* Drupal\Core\Utility\UpdateException with an appropriate error message, for
* example:
* @code
* throw new DrupalUpdateException(t('Description of what went wrong'));
* use Drupal\Core\Utility\UpdateException;
* throw new UpdateException(t('Description of what went wrong'));
* @endcode
*
* If an exception is thrown, the current update and all updates that depend on
......@@ -403,11 +405,6 @@ function update_do_one($module, $number, $dependency_map, &$context) {
$context['message'] = 'Updating ' . check_plain($module) . ' module';
}
/**
* @class Exception class used to throw error if a module update fails.
*/
class DrupalUpdateException extends Exception { }
/**
* Start the database update batch process.
*
......
<?php
/*
* @file
* Definition of Drupal\Core\Utility\UpdateException.
*/
namespace Drupal\Core\Utility;
/**
* Exception class used to throw error if a module update fails.
*/
class UpdateException extends Exception { }
......@@ -5,6 +5,8 @@
* Hooks provided by Drupal core and the System module.
*/
use Drupal\Core\Utility\UpdateException;
/**
* @addtogroup hooks
* @{
......@@ -2968,10 +2970,11 @@ function hook_install() {
* @param $sandbox
* Stores information for multipass updates. See above for more information.
*
* @throws DrupalUpdateException, PDOException
* In case of error, update hooks should throw an instance of DrupalUpdateException
* with a meaningful message for the user. If a database query fails for whatever
* reason, it will throw a PDOException.
* @throws Drupal\Core\Utility\UpdateException, PDOException
* In case of error, update hooks should throw an instance of
* Drupal\Core\Utility\UpdateException with a meaningful message for the user.
* If a database query fails for whatever reason, it will throw a
* PDOException.
*
* @return
* Optionally update hooks may return a translated string that will be displayed
......@@ -3022,7 +3025,7 @@ function hook_update_N(&$sandbox) {
return t('The update did what it was supposed to do.');
// In case of an error, simply throw an exception with an error message.
throw new DrupalUpdateException('Something went wrong; here is what you should do.');
throw new UpdateException('Something went wrong; here is what you should do.');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment