From 26c8728114d8c242d7fb71c18a5d6820e2308f33 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Tue, 4 Nov 2025 16:13:24 -0500 Subject: [PATCH] copilot suggestions --- .../choreographer/models/igc_text_state.dart | 20 ++++++++++++++----- .../repo/contextual_definition_repo.dart | 4 +++- .../choreographer/widgets/choice_array.dart | 4 +++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/pangea/choreographer/models/igc_text_state.dart b/lib/pangea/choreographer/models/igc_text_state.dart index 14566ad89..a4caab60b 100644 --- a/lib/pangea/choreographer/models/igc_text_state.dart +++ b/lib/pangea/choreographer/models/igc_text_state.dart @@ -117,11 +117,15 @@ class IGCTextState { ) { final openMatch = _openMatches.firstWhere( (m) => m.originalMatch == match.originalMatch, - orElse: () => throw "No open match found for acceptReplacement", + orElse: () => throw Exception( + 'No open match found for acceptReplacement', + ), ); if (match.updatedMatch.match.selectedChoice == null) { - throw "acceptReplacement called with null selectedChoice"; + throw Exception( + 'acceptReplacement called with null selectedChoice', + ); } match.setStatus(status); @@ -140,7 +144,9 @@ class IGCTextState { PangeaMatch ignoreReplacement(PangeaMatchState match) { final openMatch = _openMatches.firstWhere( (m) => m.originalMatch == match.originalMatch, - orElse: () => throw "No open match found for ignoreReplacement", + orElse: () => throw Exception( + 'No open match found for ignoreReplacement', + ), ); match.setStatus(PangeaMatchStatus.ignored); @@ -152,7 +158,9 @@ class IGCTextState { void undoReplacement(PangeaMatchState match) { final closedMatch = _closedMatches.firstWhere( (m) => m.originalMatch == match.originalMatch, - orElse: () => throw "No closed match found for undoReplacement", + orElse: () => throw Exception( + 'No closed match found for undoReplacement', + ), ); _closedMatches.remove(closedMatch); @@ -160,7 +168,9 @@ class IGCTextState { final choice = match.updatedMatch.match.selectedChoice?.value; if (choice == null) { - throw "match.match.selectedChoice is null in undoReplacement"; + throw Exception( + "match.match.selectedChoice is null in undoReplacement", + ); } final String replacement = match.originalMatch.match.fullText.characters diff --git a/lib/pangea/choreographer/repo/contextual_definition_repo.dart b/lib/pangea/choreographer/repo/contextual_definition_repo.dart index 90bff2f17..40d5590dd 100644 --- a/lib/pangea/choreographer/repo/contextual_definition_repo.dart +++ b/lib/pangea/choreographer/repo/contextual_definition_repo.dart @@ -53,7 +53,9 @@ class ContextualDefinitionRepo { ); if (res.statusCode != 200) { - throw res; + throw Exception( + "Contextual definition request failed with status code ${res.statusCode}", + ); } final ContextualDefinitionResponseModel response = diff --git a/lib/pangea/choreographer/widgets/choice_array.dart b/lib/pangea/choreographer/widgets/choice_array.dart index 9bb8543b1..2dddd97ee 100644 --- a/lib/pangea/choreographer/widgets/choice_array.dart +++ b/lib/pangea/choreographer/widgets/choice_array.dart @@ -153,7 +153,9 @@ class ChoiceItem extends StatelessWidget { borderRadius: BorderRadius.circular(AppConfig.borderRadius), ), ), - onLongPress: () => onLongPress!(entry.value.text, entry.key), + onLongPress: onLongPress != null + ? () => onLongPress!(entry.value.text, entry.key) + : null, onPressed: () => onPressed(entry.value.text, entry.key), child: Text( getDisplayCopy != null