Skip to content

Commit

Permalink
Rename UserDisplayedError -> FormatException
Browse files Browse the repository at this point in the history
  • Loading branch information
bannzai committed Jul 11, 2022
1 parent e80d0d7 commit 00c4ecb
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 39 deletions.
6 changes: 3 additions & 3 deletions lib/auth/exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import 'package:pilll/entity/user_error.dart';
Exception? mapFromFirebaseAuthException(
FirebaseAuthException e, LinkAccountType accountType) {
if (e.code == "provider-already-linked") {
throw UserDisplayedError(
throw FormatException(
"この${accountType.providerName}アカウントはすにでお使いのPilllのアカウントに紐付いています。画面の更新をお試しください。FAQもご覧ください。詳細: ${e.message}",
faqLinkURL:
"https://pilll.wraptas.site/a8d3c745e58c40f0b8b771bb70f7a7d1");
}
if (e.code == "credential-already-in-use") {
throw UserDisplayedError(
throw FormatException(
"この${accountType.providerName}アカウントはすでに他のPilllのアカウントに紐付いているため登録ができません。FAQもご覧ください。詳細: ${e.message}",
faqLinkURL:
"https://pilll.wraptas.site/a8d3c745e58c40f0b8b771bb70f7a7d1");
}
if (e.code == "email-already-in-use") {
throw UserDisplayedError(
throw FormatException(
"すでに${accountType.providerName}アカウントでお使いのメールアドレスが他のPilllアカウントに紐付いているため登録ができません。FAQもご覧ください。詳細: ${e.message}");
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PremiumIntroductionFooterStateStore {
"entitlements": entitlements?.identifier,
"isActivated": entitlements?.isActive,
});
throw UserDisplayedError("以前の購入情報が見つかりません。アカウントをお確かめの上再度お試しください");
throw FormatException("以前の購入情報が見つかりません。アカウントをお確かめの上再度お試しください");
} on PlatformException catch (exception, stack) {
analytics.logEvent(name: "catched_restore_exception", parameters: {
"code": exception.code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class PremiumIntroductionStore extends StateNotifier<PremiumIntroductionState> {
throw AssertionError("unexpected premium entitlements is not exists");
}
if (!premiumEntitlement.isActive) {
throw UserDisplayedError("課金の有効化が完了しておりません。しばらく時間をおいてからご確認ください");
throw FormatException("課金の有効化が完了しておりません。しばらく時間をおいてからご確認ください");
}
await callUpdatePurchaseInfo(purchaserInfo);
return Future.value(true);
Expand Down
24 changes: 12 additions & 12 deletions lib/domain/premium_introduction/util/map_to_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@ Exception? mapToDisplayedException(PlatformException exception) {
case PurchasesErrorCode.purchaseNotAllowedError:
// NOTE: Maybe simulator or emulators
// See more details: https://docs.revenuecat.com/docs/errors#--purchase_not_allowed
return UserDisplayedError("このデバイスで購入が許可されていません");
return FormatException("このデバイスで購入が許可されていません");
case PurchasesErrorCode.purchaseInvalidError:
// See more details: https://docs.revenuecat.com/docs/errors#-purchase_invalid
return UserDisplayedError("支払いに失敗しました。有効な支払い方法かどうかをご確認の上再度お試しください");
return FormatException("支払いに失敗しました。有効な支払い方法かどうかをご確認の上再度お試しください");
case PurchasesErrorCode.productNotAvailableForPurchaseError:
// Maybe missed implement or User references older payment product.
// See more details: https://docs.revenuecat.com/docs/errors#-product_not_available_for_purchase
return UserDisplayedError("対象のプランは現在販売しておりません。お手数ですがアプリを再起動の上お試しください");
return FormatException("対象のプランは現在販売しておりません。お手数ですがアプリを再起動の上お試しください");
case PurchasesErrorCode.productAlreadyPurchasedError:
// User already has same product. Announcement to restore
// See more details: https://docs.revenuecat.com/docs/errors#-product_already_purchased
// > If this occurs in production, make sure the user restores purchases to re-sync any transactions with their current App User Id.
return UserDisplayedError(
return FormatException(
"すでにプランを購入済みです。この端末で購入情報を復元する場合は「以前購入した方はこちら」から購入情報を復元してくさい");
case PurchasesErrorCode.receiptAlreadyInUseError:
return UserDisplayedError(
return FormatException(
'既に購入済み。もくは購入情報は別のユーザーで使用されています。$accountNameを確認してください');
case PurchasesErrorCode.invalidReceiptError:
return UserDisplayedError("不正な購入情報です。購入情報を確かめてください");
return FormatException("不正な購入情報です。購入情報を確かめてください");
case PurchasesErrorCode.missingReceiptFileError:
return UserDisplayedError(
return FormatException(
"購入者の情報が存在しません。$accountName で端末にサインインをした上でお試しください");
case PurchasesErrorCode.networkError:
return UserDisplayedError("ネットワーク状態が不安定です。接続状況を確認した上でお試しください。");
return FormatException("ネットワーク状態が不安定です。接続状況を確認した上でお試しください。");
case PurchasesErrorCode.invalidCredentialsError:
// Maybe developer or store settings error
// See more details: https://docs.revenuecat.com/docs/errors#---invalid_credentials
Expand All @@ -60,13 +60,13 @@ Exception? mapToDisplayedException(PlatformException exception) {
return FormatException(
"現在購入ができません。時間をおいて再度お試しください。解決しない場合は 設定 > 問い合わせ よりお問い合わせください。詳細: ${exception.message}:${exception.details}");
case PurchasesErrorCode.receiptInUseByOtherSubscriberError:
return UserDisplayedError(
return FormatException(
'購入情報は別のユーザーで使用されています。端末にログインしている$accountNameを確認してください');
case PurchasesErrorCode.invalidAppUserIdError:
return FormatException(
"ユーザーが確認できませんでした。アプリを再起動の上再度お試しください。詳細: ${exception.message}:${exception.details}");
case PurchasesErrorCode.operationAlreadyInProgressError:
return UserDisplayedError('購入処理が別途進んでおります。お時間をおいて再度ご確認ください');
return FormatException('購入処理が別途進んでおります。お時間をおいて再度ご確認ください');
case PurchasesErrorCode.unknownBackendError:
// Maybe RevenueCat incident
// See more details: https://docs.revenuecat.com/docs/errors#-unknown_backend_error
Expand All @@ -84,10 +84,10 @@ Exception? mapToDisplayedException(PlatformException exception) {
return FormatException(
"お使いのユーザーでの購入に失敗しました。時間をおいて再度お試しください。解決しない場合は 設定 > 問い合わせ よりお問い合わせください。詳細: ${exception.message}:${exception.details}");
case PurchasesErrorCode.insufficientPermissionsError:
return UserDisplayedError(
return FormatException(
'お使いの $accountName ではプランへの加入ができません。お支払い情報をご確認の上再度お試しください');
case PurchasesErrorCode.paymentPendingError:
return UserDisplayedError(
return FormatException(
'支払いが途中で止まっております。ログイン中の$accountNameで$storeNameをお確かめくだい');
case PurchasesErrorCode.invalidSubscriberAttributesError:
// See more details: https://docs.revenuecat.com/docs/errors#-invalid_subscriber_attributes
Expand Down
4 changes: 2 additions & 2 deletions lib/domain/root/root.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class RootState extends State<Root> {
errorLogger.recordError(error, stackTrace);

setState(() {
_error = UserDisplayedError(
_error = FormatException(
"起動処理でエラーが発生しました\n${ErrorMessages.connection}\n詳細:" +
error.toString());
});
Expand Down Expand Up @@ -241,7 +241,7 @@ class RootState extends State<Root> {
errorLogger.recordError(error, stackTrace);

setState(() {
_error = UserDisplayedError(
_error = FormatException(
"起動処理でエラーが発生しました\n${ErrorMessages.connection}\n詳細:" +
error.toString());
});
Expand Down
2 changes: 1 addition & 1 deletion lib/entity/user_error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class UserDisplayedError with Exception {
final String? title;
final String displayedMessage;
final String? faqLinkURL;
UserDisplayedError(this.displayedMessage, {this.title, this.faqLinkURL});
FormatException(this.displayedMessage, {this.title, this.faqLinkURL});

@override
String toString() => displayedMessage;
Expand Down
10 changes: 5 additions & 5 deletions lib/native/health_care.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Future<bool> shouldRequestForAccessToHealthKitData() async {
if (response["result"] == "success") {
return response["shouldRequestForAccessToHealthKitData"] == true;
} else if (response["result"] == "failure") {
throw UserDisplayedError(response["reason"]);
throw FormatException(response["reason"]);
} else {
throw Exception("unknown error");
}
Expand All @@ -63,7 +63,7 @@ Future<bool> requestWriteMenstrualFlowHealthKitDataPermission() async {
if (response["result"] == "success") {
return response["isSuccess"] == true;
} else if (response["result"] == "failure") {
throw UserDisplayedError(response["reason"]);
throw FormatException(response["reason"]);
} else {
throw Exception("unknown error");
}
Expand Down Expand Up @@ -100,7 +100,7 @@ Future<String> addMenstruationFlowHealthKitData(
if (response["result"] == "success") {
return response["healthKitSampleDataUUID"] as String;
} else if (response["result"] == "failure") {
throw UserDisplayedError(response["reason"]);
throw FormatException(response["reason"]);
} else {
throw Exception("unknown error");
}
Expand Down Expand Up @@ -137,7 +137,7 @@ Future<String> updateOrAddMenstruationFlowHealthKitData(
if (response["result"] == "success") {
return response["healthKitSampleDataUUID"] as String;
} else if (response["result"] == "failure") {
throw UserDisplayedError(response["reason"]);
throw FormatException(response["reason"]);
} else {
throw Exception("unknown error");
}
Expand Down Expand Up @@ -174,7 +174,7 @@ Future<void> deleteMenstruationFlowHealthKitData(
if (response["result"] == "success") {
return;
} else if (response["result"] == "failure") {
throw UserDisplayedError(response["reason"]);
throw FormatException(response["reason"]);
} else {
throw Exception("unknown error");
}
Expand Down
14 changes: 0 additions & 14 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "5.3.2"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_localizations:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -560,13 +553,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.3"
lints:
dependency: transitive
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
logging:
dependency: transitive
description:
Expand Down

0 comments on commit 00c4ecb

Please sign in to comment.