Skip to content

Commit 1a8280a

Browse files
feat: avoid throwing exceptions in isValidSeed
1 parent f19b661 commit 1a8280a

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/src/polyseed.dart

+11-7
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ class Polyseed {
2323
/// Check if a seed is a valid Polyseed
2424
static bool isValidSeed(String phrase, [PolyseedLang? lang]) {
2525
if (lang != null && !PolyseedLang.isValidPhrase(phrase)) return false;
26-
final polyseedLang = lang ?? PolyseedLang.getByPhrase(phrase);
27-
28-
return polyseedLang
29-
.normalizeSeparator(phrase)
30-
.split(polyseedLang.separator)
31-
.length ==
32-
numberOfWords;
26+
try {
27+
final polyseedLang = lang ?? PolyseedLang.getByPhrase(phrase);
28+
29+
return polyseedLang
30+
.normalizeSeparator(phrase)
31+
.split(polyseedLang.separator)
32+
.length ==
33+
numberOfWords;
34+
} on UnknownLangException catch (_) {
35+
return false;
36+
}
3337
}
3438

3539
/// Create a random [Polyseed]

0 commit comments

Comments
 (0)