1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Catch errors return error response when fetching chart or chart values fails

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala 2020-11-21 12:13:08 +02:00
parent 8c73861962
commit e1b6f914b0

View File

@ -12,14 +12,22 @@ class HelmApiRoute extends LensApi {
public async getChart(request: LensApiRequest) { public async getChart(request: LensApiRequest) {
const { params, query, response } = request; const { params, query, response } = request;
const chart = await helmService.getChart(params.repo, params.chart, query.get("version")); try {
this.respondJson(response, chart); const chart = await helmService.getChart(params.repo, params.chart, query.get("version"));
this.respondJson(response, chart);
} catch (error) {
this.respondText(response, error, 422);
}
} }
public async getChartValues(request: LensApiRequest) { public async getChartValues(request: LensApiRequest) {
const { params, query, response } = request; const { params, query, response } = request;
const values = await helmService.getChartValues(params.repo, params.chart, query.get("version")); try {
this.respondJson(response, values); const values = await helmService.getChartValues(params.repo, params.chart, query.get("version"));
this.respondJson(response, values);
} catch (error) {
this.respondText(response, error, 422);
}
} }
public async installChart(request: LensApiRequest) { public async installChart(request: LensApiRequest) {