File tree 2 files changed +10
-4
lines changed
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file based on the
11
11
12
12
### Improvements
13
13
- Set PHP 7.0 as default development version
14
+ - Get the root reason from Elasticsearch's error JSON, when available [ #1111 ] ( https://github.com/ruflin/Elastica/pull/1111 )
14
15
15
16
## [ 3.2.1] ( https://github.com/ruflin/Elastica/compare/3.2.0...3.2.1 )
16
17
Original file line number Diff line number Diff line change @@ -95,13 +95,18 @@ public function getError()
95
95
return $ error ;
96
96
}
97
97
98
+ $ rootError = $ error ;
98
99
if (isset ($ error ['root_cause ' ][0 ])) {
99
- $ error = $ error ['root_cause ' ][0 ];
100
+ $ rootError = $ error ['root_cause ' ][0 ];
100
101
}
101
102
102
- $ message = $ error ['reason ' ];
103
- if (isset ($ error ['index ' ])) {
104
- $ message .= ' [index: ' .$ error ['index ' ].'] ' ;
103
+ $ message = $ rootError ['reason ' ];
104
+ if (isset ($ rootError ['index ' ])) {
105
+ $ message .= ' [index: ' .$ rootError ['index ' ].'] ' ;
106
+ }
107
+
108
+ if (isset ($ error ['reason ' ]) && $ rootError ['reason ' ] != $ error ['reason ' ]) {
109
+ $ message .= ' [reason: ' .$ error ['reason ' ].'] ' ;
105
110
}
106
111
107
112
return $ message ;
You can’t perform that action at this time.
0 commit comments