Skip to content

Commit 57a6ed3

Browse files
committed
Make use of factory method, change error message
1 parent 93cef18 commit 57a6ed3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+50
-54
lines changed

src/Redmine/Api/CustomField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final public function list(array $params = []): array
3333
try {
3434
return $this->retrieveData('/custom_fields.json', $params);
3535
} catch (SerializerException $th) {
36-
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
36+
throw UnexpectedResponseException::create($this->getLastResponse(), $th);
3737
}
3838
}
3939

src/Redmine/Api/Group.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final public function list(array $params = []): array
3737
try {
3838
return $this->retrieveData('/groups.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

src/Redmine/Api/Issue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ final public function list(array $params = []): array
7878
try {
7979
return $this->retrieveData('/issues.json', $params);
8080
} catch (SerializerException $th) {
81-
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
81+
throw UnexpectedResponseException::create($this->getLastResponse(), $th);
8282
}
8383
}
8484

src/Redmine/Api/IssueCategory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final public function listByProject($projectIdentifier, array $params = []): arr
4646
try {
4747
return $this->retrieveData('/projects/' . strval($projectIdentifier) . '/issue_categories.json', $params);
4848
} catch (SerializerException $th) {
49-
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
49+
throw UnexpectedResponseException::create($this->getLastResponse(), $th);
5050
}
5151
}
5252

src/Redmine/Api/IssuePriority.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final public function list(array $params = []): array
3333
try {
3434
return $this->retrieveData('/enumerations/issue_priorities.json', $params);
3535
} catch (SerializerException $th) {
36-
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
36+
throw UnexpectedResponseException::create($this->getLastResponse(), $th);
3737
}
3838
}
3939

src/Redmine/Api/IssueRelation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ final public function listByIssueId(int $issueId, array $params = []): array
3535
try {
3636
return $this->retrieveData('/issues/' . strval($issueId) . '/relations.json', $params);
3737
} catch (SerializerException $th) {
38-
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
38+
throw UnexpectedResponseException::create($this->getLastResponse(), $th);
3939
}
4040
}
4141

src/Redmine/Api/IssueStatus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final public function list(array $params = []): array
3333
try {
3434
return $this->retrieveData('/issue_statuses.json', $params);
3535
} catch (SerializerException $th) {
36-
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
36+
throw UnexpectedResponseException::create($this->getLastResponse(), $th);
3737
}
3838
}
3939

src/Redmine/Api/Membership.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final public function listByProject($projectIdentifier, array $params = []): arr
4545
try {
4646
return $this->retrieveData('/projects/' . strval($projectIdentifier) . '/memberships.json', $params);
4747
} catch (SerializerException $th) {
48-
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
48+
throw UnexpectedResponseException::create($this->getLastResponse(), $th);
4949
}
5050
}
5151

src/Redmine/Api/News.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ final public function listByProject($projectIdentifier, array $params = []): arr
4141
try {
4242
return $this->retrieveData('/projects/' . strval($projectIdentifier) . '/news.json', $params);
4343
} catch (SerializerException $th) {
44-
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
44+
throw UnexpectedResponseException::create($this->getLastResponse(), $th);
4545
}
4646
}
4747

@@ -61,7 +61,7 @@ final public function list(array $params = []): array
6161
try {
6262
return $this->retrieveData('/news.json', $params);
6363
} catch (SerializerException $th) {
64-
throw new UnexpectedResponseException('The Redmine server responded with an unexpected body.', $th->getCode(), $th);
64+
throw UnexpectedResponseException::create($this->getLastResponse(), $th);
6565
}
6666
}
6767

src/Redmine/Api/Project.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)