Skip to content

Commit

Permalink
fix: 🐛 correctly create error on no_matching_indices
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 25, 2020
1 parent 90f0032 commit 6ce62da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class IndexPatternsApiClient {
query,
})
.catch((resp: any) => {
if (resp.body.statusCode === 404 && resp.body.statuscode === 'no_matching_indices') {
if (resp.body.statusCode === 404 && resp.body.attributes?.code === 'no_matching_indices') {
throw new IndexPatternMissingIndices(resp.body.message);
}

Expand Down
16 changes: 15 additions & 1 deletion src/plugins/data/server/index_patterns/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,21 @@ export function registerRoutes(http: HttpServiceSetup) {
},
});
} catch (error) {
return response.notFound();
if (
!!error.isBoom &&
!!error?.output?.payload &&
typeof error?.output?.payload === 'object'
) {
const payload = error?.output?.payload;
return response.notFound({
body: {
message: payload.message,
attributes: payload,
},
});
} else {
return response.notFound();
}
}
}
);
Expand Down

0 comments on commit 6ce62da

Please sign in to comment.