title: Pass arguments to flask error handler
body: <p>On my website, I want to be able to give the user better feedback on a 404 error than "page not found". If a view raises a 404 error, I want to pass an extra parameter to the template that describes what the view shows. For instance:</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>def get_or_404(model, attribute, value, template, **kwargs):
      try:
          return session.query(model).filter(attribute == value).one()
      except NoResultFound:
          abort(404)
  
  @app.errorhandler(404)
  def page_not_found(error):
      return render_template("404.html"), 404
  
  @app.route("project/&lt;project_id&gt;")
  def project_show(project_id):
      """
      Show the files contained in a specific project.
  
      :param int project_id: The ID of the desired project.
      """
  
      project = get_or_404(Project, Project.id, project_id, "item_not_found.html", item="project")
  
      # Other stuff
  </code></pre>
  
  <p>If the user attempts to go to a project that does not exist, then they are sent to a 404 page. If I can provide the <code>item</code> kwarg (from <code>project_show</code>) to the template <code>404.html</code>, then the template will say, for instance, "Project not found" instead of just "page not found".</p>
  
  <p>What is the best way to do this?</p>