Files
workavia-mail-front/lib/main/utils/message_toast_utils.dart
T
dab246 9b661b0688 TF-2271 Implement dns lookup to get jmap url
Signed-off-by: dab246 <tdvu@linagora.com>
(cherry picked from commit 7b0c0015a15a243b6b4aef3d78e7653d556ad109)
2023-11-21 16:54:33 +07:00

37 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:tmail_ui_user/features/home/data/exceptions/session_exceptions.dart';
import 'package:tmail_ui_user/features/login/data/network/oidc_error.dart';
import 'package:tmail_ui_user/features/login/domain/exceptions/authentication_exception.dart';
import 'package:tmail_ui_user/main/exceptions/remote_exception.dart';
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
class MessageToastUtils {
static String? getMessageByException(BuildContext context, dynamic exception) {
if (exception is CanNotFoundBaseUrl) {
return AppLocalizations.of(context).requiredUrl;
} else if (exception is CanNotFoundUserName) {
return AppLocalizations.of(context).requiredEmail;
} else if (exception is CanNotFoundPassword) {
return AppLocalizations.of(context).requiredPassword;
} else if (exception is CanNotFoundOIDCLinks) {
return AppLocalizations.of(context).ssoNotAvailable;
} else if (exception is CanNotFoundToken) {
return AppLocalizations.of(context).canNotGetToken;
} else if (exception is ConnectionTimeout || exception is BadGateway || exception is SocketError) {
return AppLocalizations.of(context).wrongUrlMessage;
} else if (exception is BadCredentialsException) {
return AppLocalizations.of(context).badCredentials;
} else if (exception is ConnectionError) {
return AppLocalizations.of(context).connectionError;
} else if (exception is UnknownError && exception.message != null) {
return '[${exception.code ?? ''}] ${exception.message}';
} else if (exception is NotFoundSessionException) {
return AppLocalizations.of(context).notFoundSession;
} else {
return null;
}
}
}