Skip to content

Commit 1e7ff16

Browse files
authored
Merge pull request #369 from Art4/add-unexpectedresponseexception-getresponse
Add new method `UnexpectedResponseException::getResponse()`
2 parents 2103392 + 4433cf0 commit 1e7ff16

Some content is hidden

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

46 files changed

+125
-55
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- New method `Redmine\Api\Project::reopen()` to reopen a project.
1515
- New method `Redmine\Api\Project::archive()` to archive a project.
1616
- New method `Redmine\Api\Project::unarchive()` to unarchive a project.
17+
- New method `UnexpectedResponseException::getResponse()` to get the last response responsible for the exception.
1718

1819
### Changed
1920

@@ -35,7 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3536
- New method `Redmine\Api\News::list()` to list news from all project.
3637
- New method `Redmine\Api\News::listByProject()` to list news from a project.
3738
- New method `Redmine\Api\Project::list()` to list projects.
38-
- New method `Redmine\Api\Query::list()` to list projects.
39+
- New method `Redmine\Api\Query::list()` to list queries.
3940
- New method `Redmine\Api\Role::list()` to list roles.
4041
- New method `Redmine\Api\Search::listByQuery()` to list search results by query.
4142
- New method `Redmine\Api\TimeEntry::list()` to list time entries.

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

0 commit comments

Comments
 (0)