-
Notifications
You must be signed in to change notification settings - Fork 75
feat(gax): add getErrorInfoList to ErrorDetails #4150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -188,6 +188,28 @@ void errorInfo_shouldUnpackErrorInfoProtoMessage() { | |
| Truth.assertThat(errorDetails.getErrorInfo()).isEqualTo(ERROR_INFO); | ||
| } | ||
|
|
||
| @Test | ||
| void unpackList_shouldReturnEmptyListIfRawErrorMessagesIsNull() { | ||
| errorDetails = ErrorDetails.builder().setRawErrorMessages(null).build(); | ||
| Truth.assertThat(errorDetails.unpackList(ErrorInfo.class)).isEmpty(); | ||
| } | ||
|
|
||
| @Test | ||
| void getErrorInfoList_shouldUnpackAllErrorInfoProtoMessages() { | ||
| ErrorInfo errorInfo2 = | ||
| ErrorInfo.newBuilder().setDomain("googleapis.com").setReason("ANOTHER_REASON").build(); | ||
|
|
||
| errorDetails = | ||
| ErrorDetails.builder() | ||
| .setRawErrorMessages( | ||
| ImmutableList.of(Any.pack(ERROR_INFO), Any.pack(DEBUG_INFO), Any.pack(errorInfo2))) | ||
| .build(); | ||
|
|
||
| Truth.assertThat(errorDetails.getErrorInfoList()) | ||
| .containsExactly(ERROR_INFO, errorInfo2) | ||
| .inOrder(); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new }
@Test
void unpackList_shouldThrowExceptionIfUnpackingErrorMessageFailed() {
Any malformedErrorType =
Any.newBuilder()
.setTypeUrl("type.googleapis.com/google.rpc.ErrorInfo")
.setValue(ByteString.copyFromUtf8("This is an invalid message!"))
.build();
errorDetails =
ErrorDetails.builder().setRawErrorMessages(ImmutableList.of(malformedErrorType)).build();
ProtocolBufferParsingException exception =
assertThrows(
ProtocolBufferParsingException.class, () -> errorDetails.unpackList(ErrorInfo.class));
Truth.assertThat(exception.getMessage())
.isEqualTo(
String.format(
"Failed to unpack %s from raw error messages", ErrorInfo.class.getSimpleName()));
}References
|
||
|
|
||
| @Test | ||
| void retryInfo_shouldUnpackRetryInfoProtoMessage() { | ||
| Truth.assertThat(errorDetails.getRetryInfo()).isEqualTo(RETRY_INFO); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per aip-193,
Each type of detail payload must be included at most once.I think this is theoretically possible but a violation of AIP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, that's extremely helpful!