Skip to content

Commit 0d26bc6

Browse files
committed
fix(graphite): minor fix/improvement to graphite error handling when doing metric exploration in query editor, fixes grafana#5778
1 parent 780ec92 commit 0d26bc6

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

public/app/core/services/alert_srv.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class AlertSrv {
1616

1717
init() {
1818
this.$rootScope.onAppEvent('alert-error', (e, alert) => {
19-
this.set(alert[0], alert[1], 'error', 0);
19+
this.set(alert[0], alert[1], 'error', 7000);
2020
}, this.$rootScope);
2121

2222
this.$rootScope.onAppEvent('alert-warning', (e, alert) => {
@@ -27,10 +27,21 @@ export class AlertSrv {
2727
this.set(alert[0], alert[1], 'success', 3000);
2828
}, this.$rootScope);
2929

30+
appEvents.on('alert-error', options => {
31+
this.set(options[0], options[1], 'error', 7000);
32+
});
33+
3034
appEvents.on('confirm-modal', this.showConfirmModal.bind(this));
3135
}
3236

3337
set(title, text, severity, timeout) {
38+
if (_.isObject(text)) {
39+
console.log('alert error', text);
40+
if (text.statusText) {
41+
text = `HTTP Error (${text.status}) ${text.statusText}`;
42+
}
43+
}
44+
3445
var newAlert = {
3546
title: title || '',
3647
text: text || '',

public/app/plugins/datasource/graphite/query_ctrl.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import moment from 'moment';
99
import gfunc from './gfunc';
1010
import {Parser} from './parser';
1111
import {QueryCtrl} from 'app/plugins/sdk';
12+
import appEvents from 'app/core/app_events';
1213

1314
export class GraphiteQueryCtrl extends QueryCtrl {
1415
static templateUrl = 'partials/query.editor.html';
@@ -141,7 +142,7 @@ export class GraphiteQueryCtrl extends QueryCtrl {
141142
}
142143
}
143144
}).catch(err => {
144-
this.error = err.message || 'Failed to issue metric query';
145+
appEvents.emit('alert-error', ['Error', err]);
145146
});
146147
}
147148

@@ -178,7 +179,7 @@ export class GraphiteQueryCtrl extends QueryCtrl {
178179
altSegments.unshift(this.uiSegmentSrv.newSegment('*'));
179180
return altSegments;
180181
}).catch(err => {
181-
this.error = err.message || 'Failed to issue metric query';
182+
appEvents.emit('alert-error', ['Error', err]);
182183
return [];
183184
});
184185
}

0 commit comments

Comments
 (0)