use of com.azure.android.communication.chat.models.ChatError in project azure-sdk-for-android by Azure.
the class CommunicationErrorResponseExceptionConverter method convert.
/**
* Maps from {@link CommunicationErrorResponseException} to {@link ChatErrorResponseException}.
* Keeps other kind of exceptions as it is.
*/
public static RuntimeException convert(Throwable throwable) {
if (throwable == null) {
return null;
}
if (throwable instanceof CommunicationErrorResponseException) {
// translate CommunicationErrorResponseException to ChatErrorResponseException
ChatError error = null;
CommunicationErrorResponseException exception = (CommunicationErrorResponseException) throwable;
if (exception.getValue() != null) {
error = ChatErrorConverter.convert(exception.getValue().getError());
}
return new ChatErrorResponseException(exception.getMessage(), exception.getResponse(), error);
} else if (throwable instanceof RuntimeException) {
// avoid double-wrapping for already unchecked exception
return (RuntimeException) throwable;
} else {
// wrap checked exception in a unchecked runtime exception
return new RuntimeException(throwable);
}
}
use of com.azure.android.communication.chat.models.ChatError in project azure-sdk-for-android by Azure.
the class CreateChatThreadResultConverter method convert.
/**
* Maps from {@link com.azure.android.communication.chat.implementation.models.CreateChatThreadResult} to
* {@link CreateChatThreadResult}.
*/
public static CreateChatThreadResult convert(com.azure.android.communication.chat.implementation.models.CreateChatThreadResult obj, ClientLogger logger) {
if (obj == null) {
return null;
}
CreateChatThreadResult createChatThreadResult = new CreateChatThreadResult().setChatThreadProperties(ChatThreadPropertiesConverter.convert(obj.getChatThread(), logger));
if (obj.getInvalidParticipants() != null) {
List<ChatError> invalidParticipants = new ArrayList<>(obj.getInvalidParticipants().size());
for (CommunicationError invalidParticipant : obj.getInvalidParticipants()) {
invalidParticipants.add(ChatErrorConverter.convert(invalidParticipant));
}
createChatThreadResult.setInvalidParticipants(invalidParticipants);
}
return createChatThreadResult;
}
Aggregations