Skip to content

Commit

Permalink
Clarify exception message for repeated builders.
Browse files Browse the repository at this point in the history
Technically these methods fail either if the field is primitive (non-message) or if the field is repeated.  However it is confusing to have a repeated field that claims to be of type 'message' that then fails with an error message that claims you need a message type.

PiperOrigin-RevId: 689042972
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Oct 23, 2024
1 parent 9f08ec5 commit c7b1582
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2709,13 +2709,12 @@ public void clear(final Builder<?> builder) {

@Override
public Message.Builder newBuilder() {
throw new UnsupportedOperationException(
"newBuilderForField() called on a non-Message type.");
throw new UnsupportedOperationException("newBuilderForField() called on a repeated field.");
}

@Override
public Message.Builder getBuilder(GeneratedMessage.Builder<?> builder) {
throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type.");
throw new UnsupportedOperationException("getFieldBuilder() called on a repeated field.");
}

@Override
Expand Down

0 comments on commit c7b1582

Please sign in to comment.