title: How to check if a custom error message is thrown by abort() in Flask?
body: <p>I'm creating a simple web app using Flask. For some views, I'm throwing a 403 error if certain conditions are not matched: </p>
  
  <pre><code>@admin.route("/employees/assign/&lt;int:id&gt;", methods=["GET", "POST"])
  @login_required
  def assign_employee(id):
      """Assign a department and a role to an employee."""
      check_admin()
  
      employee = Employee.query.get_or_404(id)
  
      if employee.is_admin:
          abort(403,f"You're not permitted to edit {employee.first_name}'s role and department.")
  
      do_something()
      return render_template(a_template)
  </code></pre>
  
  <p>To handle those errors, I've also added error handlers in my main init file. </p>
  
  <pre><code>@app.errorhandler(403)
  def fordbidden(error):
      return (
          render_template(
              "errors/403.html", title="Forbidden", error_message=error.description
          ),
          403,
      )
  </code></pre>
  
  <p>Finally, I'm displaying the error description in my Jinja template: </p>
  
  <pre><code>&lt;div style="text-align: center"&gt;
      &lt;h1&gt; 403 Error &lt;/h1&gt;
      {% if error_message %}
          &lt;h3&gt; {{error_message}} &lt;/h3&gt;
      {% else %}
          &lt;h3&gt;You're not authorised to access this ressource.&lt;/h3&gt;
      {% endif %}
      &lt;hr class="intro-divider"&gt;
      &lt;a href="{{ url_for('home.homepage') }}" class="btn btn-default btn-lg"&gt;
          &lt;i class="fa fa-home"&gt;&lt;/i&gt;
          Home
      &lt;/a&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>What I'd like to do is to display the custom error message <strong>if and only if</strong> there's one, otherwise to use the standard message defined in my template. However, it seems that my <code>{% if error_message %}</code> will always be true because the error is always passing a message by default. </p>
  
  <p>Is there a way to check for the presence of a custom error message? </p>