File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -5,18 +5,22 @@ function ErrorComponent(props) {
5
5
const { error } = props ;
6
6
let additionalInfo ;
7
7
const type = _ . get ( error , 'error.caused_by.type' ) ;
8
+ let reason = _ . get ( error , 'error.caused_by.reason' ) ;
9
+
10
+ if ( ! reason ) {
11
+ reason = _ . get ( error , 'message' ) ;
12
+ }
8
13
9
14
if ( type === 'script_exception' ) {
10
15
const scriptStack = _ . get ( error , 'error.caused_by.script_stack' ) ;
11
- const reason = _ . get ( error , 'error.caused_by.caused_by.reason' ) ;
16
+ reason = _ . get ( error , 'error.caused_by.caused_by.reason' ) ;
12
17
additionalInfo = (
13
18
< div className = "metrics_error__additional" >
14
19
< div className = "metrics_error__reason" > { reason } </ div >
15
20
< div className = "metrics_error__stack" > { scriptStack . join ( '\n' ) } </ div >
16
21
</ div >
17
22
) ;
18
- } else {
19
- const reason = _ . get ( error , 'error.caused_by.reason' ) ;
23
+ } else if ( reason ) {
20
24
additionalInfo = (
21
25
< div className = "metrics_error__additional" >
22
26
< div className = "metrics_error__reason" > { reason } </ div >
Original file line number Diff line number Diff line change @@ -7,10 +7,16 @@ export default panel => error => {
7
7
} catch ( e ) {
8
8
errorResponse = error . response ;
9
9
}
10
+ if ( ! errorResponse ) {
11
+ errorResponse = {
12
+ message : error . message ,
13
+ stack : error . stack
14
+ } ;
15
+ }
10
16
result [ panel . id ] = {
11
17
id : panel . id ,
12
18
statusCode : error . statusCode ,
13
- error : errorResponse || error ,
19
+ error : errorResponse ,
14
20
series : [ ]
15
21
} ;
16
22
return result ;
Original file line number Diff line number Diff line change 1
1
import buildProcessorFunction from './build_processor_function' ;
2
2
import processors from './response_processors/series' ;
3
+ import { get } from 'lodash' ;
3
4
4
5
export default function handleResponseBody ( panel ) {
5
6
return resp => {
@@ -8,7 +9,13 @@ export default function handleResponseBody(panel) {
8
9
err . response = JSON . stringify ( resp ) ;
9
10
throw err ;
10
11
}
11
- const keys = Object . keys ( resp . aggregations ) ;
12
+ const aggregations = get ( resp , 'aggregations' ) ;
13
+ if ( ! aggregations ) {
14
+ const message = `The aggregations key is missing from the response,
15
+ check your permissions for this request.` ;
16
+ throw Error ( message ) ;
17
+ }
18
+ const keys = Object . keys ( aggregations ) ;
12
19
if ( keys . length !== 1 ) throw Error ( 'There should only be one series per request.' ) ;
13
20
const seriesId = keys [ 0 ] ;
14
21
const series = panel . series . find ( s => s . id === seriesId ) ;
You can’t perform that action at this time.
0 commit comments