ChangeApiImpl: Don't catch RestApiException when editing hashtag

If a RestApiException (or, importantly, any subclass of RestApiException)
is raised when performing the hashtag edit, it is caught and rethrown as
RestApiException with a generic "Cannot post hashtags" message.

Any specific exception type, and its message, is then lost.

Don't catch RestApiException. Instead let it propagate up to the caller.

Also add tests to confirm the behavior when adding hashtags with and
without the "edit hashtags" permission.

Change-Id: Ib708d871462972b3f0644351d062de08ef1c9bee
This commit is contained in:
David Pursehouse
2017-03-29 21:05:39 +09:00
parent 01a139b2e9
commit 483baef151
2 changed files with 23 additions and 1 deletions

View File

@@ -454,7 +454,7 @@ class ChangeApiImpl implements ChangeApi {
public void setHashtags(HashtagsInput input) throws RestApiException {
try {
postHashtags.apply(change, input);
} catch (RestApiException | UpdateException e) {
} catch (UpdateException e) {
throw new RestApiException("Cannot post hashtags", e);
}
}