long sentry error on missing grammar copy

This commit is contained in:
ggurdin 2024-11-04 12:42:36 -05:00
parent 4c26e4629a
commit 506629b07f
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
3 changed files with 21 additions and 4 deletions

View file

@ -1,6 +1,7 @@
// ignore_for_file: constant_identifier_names
import 'package:collection/collection.dart';
import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -44,11 +45,19 @@ extension MorphologicalCategoriesExtension on MorphologicalCategories {
/// Convert string to enum
static MorphologicalCategories? fromString(String category) {
return MorphologicalCategories.values.firstWhereOrNull(
final morph = MorphologicalCategories.values.firstWhereOrNull(
(e) =>
e.toShortString() ==
category.toLowerCase().replaceAll(RegExp(r'[,\[\]]'), ''),
);
if (morph == null) {
ErrorHandler.logError(
e: "Missing morphological category",
s: StackTrace.current,
data: {"category": category},
);
}
return morph;
}
String getDisplayCopy(BuildContext context) {

View file

@ -1,4 +1,5 @@
import 'package:collection/collection.dart';
import 'package:fluffychat/pangea/utils/error_handler.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
@ -31,9 +32,17 @@ extension GrammarCopyPOSExtension on GrammarCopyPOS {
}
GrammarCopyPOS? fromString(String categoryName) {
return GrammarCopyPOS.values.firstWhereOrNull(
final pos = GrammarCopyPOS.values.firstWhereOrNull(
(pos) => pos.toShortString() == categoryName.toLowerCase(),
);
if (pos == null) {
ErrorHandler.logError(
e: "Missing part of speech",
s: StackTrace.current,
data: {"category": categoryName},
);
}
return pos;
}
String getDisplayCopy(BuildContext context) {

View file

@ -450,8 +450,7 @@ String? getGrammarCopy({
default:
debugger(when: kDebugMode);
ErrorHandler.logError(
e: Exception('Need to add copy for $key to intl_en.arb'),
m: 'Need to add copy for $key to intl_en.arb',
e: 'Need to add copy to intl_en.arb',
data: {
'tag': key,
'context': context,