handle parsing exception for OIDCHttpClient::checkOIDCIsAvailable()
This commit is contained in:
committed by
Dat H. Pham
parent
7a27415295
commit
005790ae5f
@@ -13,6 +13,7 @@ import 'package:model/oidc/response/oidc_response.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/extensions/service_path_extension.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/config/oidc_constant.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/endpoint.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/exceptions/login_exception.dart';
|
||||
import 'package:tmail_ui_user/features/login/data/network/oidc_error.dart';
|
||||
import 'package:tmail_ui_user/main/utils/app_config.dart';
|
||||
import 'package:dio/dio.dart' show DioError;
|
||||
@@ -40,6 +41,9 @@ class OIDCHttpClient {
|
||||
} else {
|
||||
return OIDCResponse.fromJson(jsonDecode(result));
|
||||
}
|
||||
} on FormatException catch (exception) {
|
||||
log('checkOIDCIsAvailable(): error while parsing server response (JSON expected): ${exception.message}');
|
||||
throw InvalidOIDCResponseException();
|
||||
} on DioError catch (exception) {
|
||||
if (exception.error is HandshakeException) {
|
||||
throw exception.error!;
|
||||
|
||||
@@ -5,6 +5,8 @@ class NotFoundDataResourceRecordException implements Exception {}
|
||||
|
||||
class NotFoundUrlException implements Exception {}
|
||||
|
||||
class InvalidOIDCResponseException implements Exception {}
|
||||
|
||||
class NoSuitableBrowserForOIDCException implements Exception {
|
||||
|
||||
static const noBrowserAvailableCode = 'no_browser_available';
|
||||
|
||||
@@ -274,7 +274,7 @@ class LoginController extends ReloadableController {
|
||||
}
|
||||
|
||||
void _handleCheckOIDCIsAvailableFailure(CheckOIDCIsAvailableFailure failure) {
|
||||
if (failure.exception is CanNotFoundOIDCLinks) {
|
||||
if (failure.exception is CanNotFoundOIDCLinks || failure.exception is InvalidOIDCResponseException) {
|
||||
_handleCommonOIDCFailure();
|
||||
} else {
|
||||
loginFormType.value = LoginFormType.retry;
|
||||
|
||||
Reference in New Issue
Block a user