@@ -37,7 +37,7 @@ final public function list(array $params = []): array
3737 try {
3838 return $ this ->retrieveData ('/projects.json ' , $ params );
3939 } catch (SerializerException $ th ) {
40- throw new UnexpectedResponseException ( ' The Redmine server responded with an unexpected body. ' , $ th -> getCode (), $ th );
40+ throw UnexpectedResponseException:: create ( $ this -> getLastResponse (), $ th );
4141 }
4242 }
4343
@@ -224,7 +224,7 @@ final public function close($projectIdentifier): bool
224224 $ lastResponse = $ this ->getLastResponse ();
225225
226226 if ($ lastResponse ->getStatusCode () !== 204 ) {
227- throw new UnexpectedResponseException ( ' The Redmine server replied with the status code ' . $ lastResponse-> getStatusCode () );
227+ throw UnexpectedResponseException:: create ( $ lastResponse );
228228 }
229229
230230 return true ;
@@ -259,7 +259,7 @@ final public function reopen($projectIdentifier): bool
259259 $ lastResponse = $ this ->getLastResponse ();
260260
261261 if ($ lastResponse ->getStatusCode () !== 204 ) {
262- throw new UnexpectedResponseException ( ' The Redmine server replied with the status code ' . $ lastResponse-> getStatusCode () );
262+ throw UnexpectedResponseException:: create ( $ lastResponse );
263263 }
264264
265265 return true ;
@@ -294,7 +294,7 @@ final public function archive($projectIdentifier): bool
294294 $ lastResponse = $ this ->getLastResponse ();
295295
296296 if ($ lastResponse ->getStatusCode () !== 204 ) {
297- throw new UnexpectedResponseException ( ' The Redmine server replied with the status code ' . $ lastResponse-> getStatusCode () );
297+ throw UnexpectedResponseException:: create ( $ lastResponse );
298298 }
299299
300300 return true ;
@@ -329,7 +329,7 @@ final public function unarchive($projectIdentifier): bool
329329 $ lastResponse = $ this ->getLastResponse ();
330330
331331 if ($ lastResponse ->getStatusCode () !== 204 ) {
332- throw new UnexpectedResponseException ( ' The Redmine server replied with the status code ' . $ lastResponse-> getStatusCode () );
332+ throw UnexpectedResponseException:: create ( $ lastResponse );
333333 }
334334
335335 return true ;
0 commit comments