Answers.Body: <p>I recently asked P&amp;T about a similar issue, although it was for the <code>onBeforeSaveEntry</code> event (not <code>onBeforeDeleteEntry</code>) -- it turns out that you need to set the error on a specific field, not the entry as a whole. I don't know if this is the case for your problem, but perhaps worth trying something like this:</p>
  
  <p><code>$event-&gt;params['entry']-&gt;addError('title', 'Cannot delete because blah blah blah');</code></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-04-18T23:30:43.457Z
Answers.LastActivityDate: 2017-04-18T23:30:43.457Z
Answers.UserDisplayName: Jordan Lev
Body: <p>I know I can set errors and notices in the CP with <code>setError()</code> and <code>setNotice()</code>.
  But it gets overruled by the default error message in my event.</p>
  
  <p>I have a <code>beforeDeleteEntry</code> event which stops the deleting of an entry by using <code>$event-&gt;performAction = false;</code>. This makes Craft display a default error "can't delete entry". I'd like to add more to that error or show another one, but using <code>setError()</code> does not work. A <code>setNotice()</code> is shown however so I suppose the error gets replaced by the default Craft error.</p>
  
  <p>Can I do something about that?</p>
  
Tags: <plugin-development><error-message><events>
Title: How to overrule Craft error messages with custom setError()?
ThreadText: # How to overrule Craft error messages with custom setError()?
  
  (Asked by: username_0 on 2017-04-13)
  
  I know I can set errors and notices in the CP with `setError()` and `setNotice()`.
  But it gets overruled by the default error message in my event.
  
  I have a `beforeDeleteEntry` event which stops the deleting of an entry by using `$event->performAction = false;`. This makes Craft display a default error "can't delete entry". I'd like to add more to that error or show another one, but using `setError()` does not work. A `setNotice()` is shown however so I suppose the error gets replaced by the default Craft error.
  
  Can I do something about that?
  
  **Tags:** plugin-development, error-message, events
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-04-18. Score: 1
  
  I recently asked P&T about a similar issue, although it was for the `onBeforeSaveEntry` event (not `onBeforeDeleteEntry`) -- it turns out that you need to set the error on a specific field, not the entry as a whole. I don't know if this is the case for your problem, but perhaps worth trying something like this:
  
  `$event->params['entry']->addError('title', 'Cannot delete because blah blah blah');`
  
  
  ---
  
  