Skip to content

Commit

Permalink
Return Boom errors directly to the browser for Time Series Visual Bui…
Browse files Browse the repository at this point in the history
…lder (elastic#11656)

* Fixed elastic#11643 - Return Boom errors directly to the browser

* Checking for 401 and boom errors instead of just boom errors

* removing the returns from the hapi routes
  • Loading branch information
simianhacker authored and snide committed May 30, 2017
1 parent c7af1f2 commit fc8136d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default panel => error => {
console.log(error);
if (error.isBoom && error.status === 401) throw error;
const result = {};
let errorResponse;
try {
Expand Down
7 changes: 5 additions & 2 deletions src/core_plugins/metrics/server/routes/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ export default (server) => {
path: '/api/metrics/fields',
method: 'GET',
handler: (req, reply) => {
return getFields(req)
getFields(req)
.then(reply)
.catch(() => reply([]));
.catch((err) => {
if (err.isBoom && err.status === 401) return reply(err);
reply([]);
});
}
});

Expand Down
3 changes: 1 addition & 2 deletions src/core_plugins/metrics/server/routes/vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ export default (server) => {
path: '/api/metrics/vis/data',
method: 'POST',
handler: (req, reply) => {
return getVisData(req)
getVisData(req)
.then(reply)
.catch(err => {
console.error(err.stack);
reply(Boom.wrap(err, 400));
});
}
Expand Down

0 comments on commit fc8136d

Please sign in to comment.