@@ -89,7 +89,7 @@ public function execute(ProcessState $state): void
89
89
// Handle empty results
90
90
try {
91
91
if (!\in_array ($ response ->getStatusCode (), $ options ['valid_response_code ' ], false )) {
92
- $ state ->setErrorOutput ($ response ->getContent ());
92
+ $ state ->setErrorOutput ($ response ->getContent (false ));
93
93
94
94
if (TaskConfiguration::STRATEGY_SKIP === $ state ->getTaskConfiguration ()->getErrorStrategy ()) {
95
95
$ state ->setSkipped (true );
@@ -102,17 +102,31 @@ public function execute(ProcessState $state): void
102
102
103
103
$ state ->setOutput ($ response ->getContent ());
104
104
} catch (\Throwable $ e ) {
105
- $ this ->logger ->error (
106
- 'REST request failed ' ,
107
- [
108
- 'client ' => $ options ['client ' ],
109
- 'options ' => $ options ,
110
- 'request_options ' => $ requestOptions ,
111
- 'message ' => $ e ->getMessage (),
112
- 'raw_headers ' => $ response ->getHeaders (false ),
113
- 'raw_body ' => $ response ->getContent (false ),
114
- ]
115
- );
105
+ $ allowRedirectionException = false ;
106
+ $ allowClientException = false ;
107
+ foreach ($ options ['valid_response_code ' ] as $ code ) {
108
+ if ($ code >= 300 && $ code < 400 ) {
109
+ $ allowRedirectionException = true ;
110
+ }
111
+ if ($ code >= 400 && $ code < 500 ) {
112
+ $ allowClientException = true ;
113
+ }
114
+ }
115
+ if (!($ allowRedirectionException && $ e instanceof RedirectionExceptionInterface)
116
+ && !($ allowClientException && $ e instanceof ClientExceptionInterface)
117
+ ) {
118
+ $ this ->logger ->error (
119
+ 'REST request failed ' ,
120
+ [
121
+ 'client ' => $ options ['client ' ],
122
+ 'options ' => $ options ,
123
+ 'request_options ' => $ requestOptions ,
124
+ 'message ' => $ e ->getMessage (),
125
+ 'raw_headers ' => $ response ->getHeaders (false ),
126
+ 'raw_body ' => $ response ->getContent (false ),
127
+ ]
128
+ );
129
+ }
116
130
117
131
throw $ e ;
118
132
}
0 commit comments