From 0d26bc63aee291f0f89c1fee54b3967278ffd58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Thu, 11 Aug 2016 10:29:28 +0200 Subject: [PATCH] fix(graphite): minor fix/improvement to graphite error handling when doing metric exploration in query editor, fixes #5778 --- public/app/core/services/alert_srv.ts | 13 ++++++++++++- .../app/plugins/datasource/graphite/query_ctrl.ts | 5 +++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/public/app/core/services/alert_srv.ts b/public/app/core/services/alert_srv.ts index edfff2e8d00..d8699b46fa6 100644 --- a/public/app/core/services/alert_srv.ts +++ b/public/app/core/services/alert_srv.ts @@ -16,7 +16,7 @@ export class AlertSrv { init() { this.$rootScope.onAppEvent('alert-error', (e, alert) => { - this.set(alert[0], alert[1], 'error', 0); + this.set(alert[0], alert[1], 'error', 7000); }, this.$rootScope); this.$rootScope.onAppEvent('alert-warning', (e, alert) => { @@ -27,10 +27,21 @@ export class AlertSrv { this.set(alert[0], alert[1], 'success', 3000); }, this.$rootScope); + appEvents.on('alert-error', options => { + this.set(options[0], options[1], 'error', 7000); + }); + appEvents.on('confirm-modal', this.showConfirmModal.bind(this)); } set(title, text, severity, timeout) { + if (_.isObject(text)) { + console.log('alert error', text); + if (text.statusText) { + text = `HTTP Error (${text.status}) ${text.statusText}`; + } + } + var newAlert = { title: title || '', text: text || '', diff --git a/public/app/plugins/datasource/graphite/query_ctrl.ts b/public/app/plugins/datasource/graphite/query_ctrl.ts index 84b71685f17..93977dc143d 100644 --- a/public/app/plugins/datasource/graphite/query_ctrl.ts +++ b/public/app/plugins/datasource/graphite/query_ctrl.ts @@ -9,6 +9,7 @@ import moment from 'moment'; import gfunc from './gfunc'; import {Parser} from './parser'; import {QueryCtrl} from 'app/plugins/sdk'; +import appEvents from 'app/core/app_events'; export class GraphiteQueryCtrl extends QueryCtrl { static templateUrl = 'partials/query.editor.html'; @@ -141,7 +142,7 @@ export class GraphiteQueryCtrl extends QueryCtrl { } } }).catch(err => { - this.error = err.message || 'Failed to issue metric query'; + appEvents.emit('alert-error', ['Error', err]); }); } @@ -178,7 +179,7 @@ export class GraphiteQueryCtrl extends QueryCtrl { altSegments.unshift(this.uiSegmentSrv.newSegment('*')); return altSegments; }).catch(err => { - this.error = err.message || 'Failed to issue metric query'; + appEvents.emit('alert-error', ['Error', err]); return []; }); }