diff --git a/puppetboard/app.py b/puppetboard/app.py index 596a6ac..bf03ee4 100644 --- a/puppetboard/app.py +++ b/puppetboard/app.py @@ -17,6 +17,7 @@ from flask import ( ) from pypuppetdb import connect +from pypuppetdb.errors import EmptyResponseError from pypuppetdb.QueryBuilder import * from puppetboard.forms import (CatalogForm, QueryForm) @@ -115,10 +116,14 @@ class NoContent(ex.HTTPException): abort.mapping[204] = NoContent - -@app.errorhandler(204) -def no_content(e): - return '', 204 +try: + @app.errorhandler(204) + def no_content(e): + return '', 204 +except KeyError: + @app.errorhandler(EmptyResponseError) + def no_content(e): + return '', 204 @app.errorhandler(400)