From 00c4ecb52268a18e9358069efeb7830f74e61f19 Mon Sep 17 00:00:00 2001 From: bannzai Date: Tue, 12 Jul 2022 08:16:14 +0900 Subject: [PATCH] Rename UserDisplayedError -> FormatException --- lib/auth/exception.dart | 6 ++--- .../premium_introduction_footer_store.dart | 2 +- .../premium_introduction_store.dart | 2 +- .../util/map_to_error.dart | 24 +++++++++---------- lib/domain/root/root.dart | 4 ++-- lib/entity/user_error.dart | 2 +- lib/native/health_care.dart | 10 ++++---- pubspec.lock | 14 ----------- 8 files changed, 25 insertions(+), 39 deletions(-) diff --git a/lib/auth/exception.dart b/lib/auth/exception.dart index 5eb3dd271b..913f541890 100644 --- a/lib/auth/exception.dart +++ b/lib/auth/exception.dart @@ -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; diff --git a/lib/domain/premium_introduction/components/premium_introduction_footer_store.dart b/lib/domain/premium_introduction/components/premium_introduction_footer_store.dart index dbb834d2b2..454aaa240b 100644 --- a/lib/domain/premium_introduction/components/premium_introduction_footer_store.dart +++ b/lib/domain/premium_introduction/components/premium_introduction_footer_store.dart @@ -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, diff --git a/lib/domain/premium_introduction/premium_introduction_store.dart b/lib/domain/premium_introduction/premium_introduction_store.dart index 1df1713a81..4a1c782a97 100644 --- a/lib/domain/premium_introduction/premium_introduction_store.dart +++ b/lib/domain/premium_introduction/premium_introduction_store.dart @@ -106,7 +106,7 @@ class PremiumIntroductionStore extends StateNotifier { throw AssertionError("unexpected premium entitlements is not exists"); } if (!premiumEntitlement.isActive) { - throw UserDisplayedError("課金の有効化が完了しておりません。しばらく時間をおいてからご確認ください"); + throw FormatException("課金の有効化が完了しておりません。しばらく時間をおいてからご確認ください"); } await callUpdatePurchaseInfo(purchaserInfo); return Future.value(true); diff --git a/lib/domain/premium_introduction/util/map_to_error.dart b/lib/domain/premium_introduction/util/map_to_error.dart index b343618c91..6f2e75d14b 100644 --- a/lib/domain/premium_introduction/util/map_to_error.dart +++ b/lib/domain/premium_introduction/util/map_to_error.dart @@ -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 @@ -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 @@ -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 diff --git a/lib/domain/root/root.dart b/lib/domain/root/root.dart index 90be3c6b4a..74772a708f 100644 --- a/lib/domain/root/root.dart +++ b/lib/domain/root/root.dart @@ -209,7 +209,7 @@ class RootState extends State { errorLogger.recordError(error, stackTrace); setState(() { - _error = UserDisplayedError( + _error = FormatException( "起動処理でエラーが発生しました\n${ErrorMessages.connection}\n詳細:" + error.toString()); }); @@ -241,7 +241,7 @@ class RootState extends State { errorLogger.recordError(error, stackTrace); setState(() { - _error = UserDisplayedError( + _error = FormatException( "起動処理でエラーが発生しました\n${ErrorMessages.connection}\n詳細:" + error.toString()); }); diff --git a/lib/entity/user_error.dart b/lib/entity/user_error.dart index 886f7a833b..33b441ea7b 100644 --- a/lib/entity/user_error.dart +++ b/lib/entity/user_error.dart @@ -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; diff --git a/lib/native/health_care.dart b/lib/native/health_care.dart index 94f245af7c..88bcaa6395 100644 --- a/lib/native/health_care.dart +++ b/lib/native/health_care.dart @@ -42,7 +42,7 @@ Future 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"); } @@ -63,7 +63,7 @@ Future 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"); } @@ -100,7 +100,7 @@ Future 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"); } @@ -137,7 +137,7 @@ Future 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"); } @@ -174,7 +174,7 @@ Future deleteMenstruationFlowHealthKitData( if (response["result"] == "success") { return; } else if (response["result"] == "failure") { - throw UserDisplayedError(response["reason"]); + throw FormatException(response["reason"]); } else { throw Exception("unknown error"); } diff --git a/pubspec.lock b/pubspec.lock index 06766d630b..87f4926f84 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -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 @@ -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: