setStateByException method

void setStateByException(
  1. Object error
)

Обновляет состояние приложения на основе возникшего исключения.

Если error является ApiException, состояние устанавливается в зависимости от типа исключения:

Для остальных исключений устанавливается InternalErrorState.

Implementation

void setStateByException(Object error) {
  if (error is ApiException) {
    switch (error.type) {
      case ApiExceptionType.auth:
      case ApiExceptionType.other:
        setState(ApiErrorState(error));
        break;
      case ApiExceptionType.badRequest:
        setState(BadRequestState(error));
        break;
      case ApiExceptionType.timeout:
        setState(NoInternetState(error));
        break;
    }
  } else {
    setState(InternalErrorState(error));
  }
}