mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 10:23:14 -04:00
parent
bea91c9dbd
commit
cac7054ae7
2 changed files with 21 additions and 0 deletions
|
@ -21,6 +21,22 @@ describe('formatMsg', function () {
|
||||||
expect(actual).to.equal('error message');
|
expect(actual).to.equal('error message');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should handle a simple Angular $http error object', function () {
|
||||||
|
var err = {
|
||||||
|
data: {
|
||||||
|
statusCode: 403,
|
||||||
|
error: 'Forbidden',
|
||||||
|
message: '[security_exception] action [indices:data/read/mget] is unauthorized for user [user]'
|
||||||
|
},
|
||||||
|
status: 403,
|
||||||
|
config: {},
|
||||||
|
statusText: 'Forbidden'
|
||||||
|
};
|
||||||
|
var actual = formatMsg(err);
|
||||||
|
|
||||||
|
expect(actual).to.equal('Error 403 Forbidden: [security_exception] action [indices:data/read/mget] is unauthorized for user [user]');
|
||||||
|
});
|
||||||
|
|
||||||
it('should handle an extended elasticsearch error', function () {
|
it('should handle an extended elasticsearch error', function () {
|
||||||
var err = {
|
var err = {
|
||||||
resp : {
|
resp : {
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
define(function (require) {
|
define(function (require) {
|
||||||
|
var _ = require('lodash');
|
||||||
|
var has = _.has;
|
||||||
var formatESMsg = require('ui/notify/lib/_format_es_msg');
|
var formatESMsg = require('ui/notify/lib/_format_es_msg');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +24,9 @@ define(function (require) {
|
||||||
rtn += esMsg;
|
rtn += esMsg;
|
||||||
} else if (err instanceof Error) {
|
} else if (err instanceof Error) {
|
||||||
rtn += formatMsg.describeError(err);
|
rtn += formatMsg.describeError(err);
|
||||||
|
} else if (has(err, 'status') && has(err, 'data')) {
|
||||||
|
// is an Angular $http "error object"
|
||||||
|
rtn += 'Error ' + err.status + ' ' + err.statusText + ': ' + err.data.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rtn;
|
return rtn;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue