Skip to content

Conversation

@AleksVira
Copy link

No description provided.

_catsView?.populate(catPresentation)
} catch (e: SocketTimeoutException) {
_catsView?.showError("Не удалось получить ответ от сервера")
} catch (e: Exception) {

This comment was marked as resolved.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хоть CatsPresenter и не используется, поправил с учётом возможности CancellationException.
И для ViewModel тоже.

)
_catsView?.populate(catPresentation)
} catch (e: SocketTimeoutException) {
_catsView?.showError("Не удалось получить ответ от сервера")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

минорно, но лучше выносить в ресурсы

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Вынес, и во ViewModel тоже.
Строковый ресурс, чтобы Context не тащить во ViewModel, через фабрику корректно передавать?
Или существуют способы изящнее?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

в целом я бы так не делал, но для домашки вполне рабочий вариант) можно обойтись без контекста, вынеся получение строк в какой то provider, в котором будет контекст уже

_catsLiveData.value = Result.Success(catPresentation)
} catch (_: SocketTimeoutException) {
_catsLiveData.value = Result.Error(Exception("Не удалось получить ответ от сервера"))
} catch (e: Exception) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут дублирование с exceptionHandler, все будет перехвачено и в exceptionHandler уже ничего не попадет

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всю обработку ошибок перенёс в CoroutineExceptionHandler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants