2020-12-25 09:58:34 +01:00
|
|
|
import 'package:famedlysdk/famedlysdk.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
|
|
|
|
extension LocalizedExceptionExtension on Object {
|
|
|
|
String toLocalizedString(BuildContext context) {
|
|
|
|
if (this is MatrixException) {
|
|
|
|
switch ((this as MatrixException).error) {
|
|
|
|
case MatrixError.M_FORBIDDEN:
|
|
|
|
return L10n.of(context).noPermission;
|
|
|
|
case MatrixError.M_LIMIT_EXCEEDED:
|
|
|
|
return L10n.of(context).tooManyRequestsWarning;
|
|
|
|
default:
|
|
|
|
return (this as MatrixException).errorMessage;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this is MatrixConnectionException) {
|
|
|
|
L10n.of(context).noConnectionToTheServer;
|
|
|
|
}
|
2021-02-06 20:41:24 +01:00
|
|
|
Logs().w('Something went wrong: ', this);
|
2020-12-25 09:58:34 +01:00
|
|
|
return L10n.of(context).oopsSomethingWentWrong;
|
|
|
|
}
|
|
|
|
}
|