RFR: 1616: Improve error message when an author isn't found in GitLab
Zhao Song
zsong at openjdk.org
Wed Oct 5 17:12:24 UTC 2022
On Wed, 5 Oct 2022 16:39:42 GMT, Erik Joelsson <erikj at openjdk.org> wrote:
>> Improved the error message in GitLabMergeRequest:author
>
> forge/src/main/java/org/openjdk/skara/forge/gitlab/GitLabMergeRequest.java line 85:
>
>> 83: return author.get();
>> 84: } else {
>> 85: throw new IllegalArgumentException("Unknown username: " + username);
>
> I don't think IllegalArgumentException is correct here. It's meant to be thrown when a method receives a bad argument, but this method doesn't take arguments. We don't really have a reason to define a new exception type either, so a plain `RuntimeException` is probably better, at least for now.
>
> I'm usually for short and concise messages, but in this case I think we can add some more details. Something like `"Author of merge request unknown: " + username`
Ok, I also thought about the type of exception yesterday. I was thinking that the username is an argument of `user(username)`, but throw exception in method `user` is a little complex.
I will change it to RuntimeException and make the error message have more details.
-------------
PR: https://git.openjdk.org/skara/pull/1390
More information about the skara-dev
mailing list