Support for new Flask errorhandling

This commit is contained in:
Mike Terzo
2017-02-01 18:36:51 -05:00
parent 58d613ba02
commit 596f0110f1

View File

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