-
Notifications
You must be signed in to change notification settings - Fork 241
04_Coroutines_Homework #267
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
base: development
Are you sure you want to change the base?
Conversation
| _catsView?.populate(catPresentation) | ||
| } catch (e: SocketTimeoutException) { | ||
| _catsView?.showError("Не удалось получить ответ от сервера") | ||
| } catch (e: Exception) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Хоть CatsPresenter и не используется, поправил с учётом возможности CancellationException.
И для ViewModel тоже.
| ) | ||
| _catsView?.populate(catPresentation) | ||
| } catch (e: SocketTimeoutException) { | ||
| _catsView?.showError("Не удалось получить ответ от сервера") |
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.
минорно, но лучше выносить в ресурсы
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.
Вынес, и во ViewModel тоже.
Строковый ресурс, чтобы Context не тащить во ViewModel, через фабрику корректно передавать?
Или существуют способы изящнее?
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.
в целом я бы так не делал, но для домашки вполне рабочий вариант) можно обойтись без контекста, вынеся получение строк в какой то provider, в котором будет контекст уже
| _catsLiveData.value = Result.Success(catPresentation) | ||
| } catch (_: SocketTimeoutException) { | ||
| _catsLiveData.value = Result.Error(Exception("Не удалось получить ответ от сервера")) | ||
| } catch (e: Exception) { |
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.
тут дублирование с exceptionHandler, все будет перехвачено и в exceptionHandler уже ничего не попадет
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.
Всю обработку ошибок перенёс в CoroutineExceptionHandler
No description provided.