mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -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');
|
||||
});
|
||||
|
||||
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 () {
|
||||
var err = {
|
||||
resp : {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
define(function (require) {
|
||||
var _ = require('lodash');
|
||||
var has = _.has;
|
||||
var formatESMsg = require('ui/notify/lib/_format_es_msg');
|
||||
|
||||
/**
|
||||
|
@ -22,6 +24,9 @@ define(function (require) {
|
|||
rtn += esMsg;
|
||||
} else if (err instanceof Error) {
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue