Answers.Body: <p>Currently not, but as Lindsey points out, that's not a bad idea for a <a href="http://feedback.craftcms.com" rel="nofollow">feature request</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T08:43:55.663Z
Answers.Text: Thanks Brad! I've added a feature request: http://feedback.craftcms.com/forums/285221-feature-requests/suggestions/11499702-add-the-option-to-display-a-custom-error-message-w
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-19T03:30:15.907Z
Answers.LastActivityDate: 2016-01-19T03:30:15.907Z
Answers.UserDisplayName: Brad Bell
Body: <p>I've got a plugin migration that returns <code>false</code> from its <code>safeUp()</code> method when certain conditions aren't met.</p>
  
  <p>Upon returning <code>false</code> from the migration, the update stalls, rolls back changes and gives an error screen with a generic error message – i.e. "There was a problem updating your database".</p>
  
  <p>For many users (i.e. those who aren't tech savvy enough to check logs etc.) this message isn't very helpful at all. Is it possible to add a custom message when a migration is aborted?</p>
  
  <p>I've tried throwing an exception inside <code>safeUp()</code>, which gets <em>logged</em> but does not display on the error screen.</p>
  
  <p>If I use a <code>die()</code> statement for the error message, Craft <em>does</em> display it on the error screen, but that makes the whole update process halt, which seems like an unsafe thing to do.</p>
  
  <p>I've also attempted to use <code>craft()-&gt;userSession-&gt;setError()</code>, but that doesn't appear to be working, either.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-01-19T00:38:42.927Z
Comments.Text: Great idea! I'm gonna bet this one lands on "feature request" ;)
Comments.UserDisplayName: Lindsey D
Tags: <plugin-development><migration>
Title: Is it possible to add a custom error message when a migration is aborted?
ThreadText: # Is it possible to add a custom error message when a migration is aborted?
  
  (Asked by: username_0 on 2016-01-19)
  
  I've got a plugin migration that returns `false` from its `safeUp()` method when certain conditions aren't met.
  
  Upon returning `false` from the migration, the update stalls, rolls back changes and gives an error screen with a generic error message – i.e. "There was a problem updating your database".
  
  For many users (i.e. those who aren't tech savvy enough to check logs etc.) this message isn't very helpful at all. Is it possible to add a custom message when a migration is aborted?
  
  I've tried throwing an exception inside `safeUp()`, which gets *logged* but does not display on the error screen.
  
  If I use a `die()` statement for the error message, Craft *does* display it on the error screen, but that makes the whole update process halt, which seems like an unsafe thing to do.
  
  I've also attempted to use `craft()->userSession->setError()`, but that doesn't appear to be working, either.
  
  **Tags:** plugin-development, migration
  
  > **Comments:**
  > **username_1**: Great idea! I'm gonna bet this one lands on "feature request" ;)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2016-01-19. Score: 2 | Accepted answer
  
  Currently not, but as username_1 points out, that's not a bad idea for a [feature request](http://feedback.craftcms.com).
  
  > **Comments:**
  > **username_0**: Thanks username_2! I've added a feature request: http://feedback.craftcms.com/forums/285221-feature-requests/suggestions/11499702-add-the-option-to-display-a-custom-error-message-w  
  
  ---
  
  