Merge pull request #4587 from pangeachat/sentry
fix: throw more specific errors, always send stack trace to sentry, d…
This commit is contained in:
commit
997b54729b
6 changed files with 58 additions and 25 deletions
|
|
@ -38,11 +38,11 @@ class ActivityRolesModel {
|
|||
}
|
||||
|
||||
static ActivityRolesModel fromJson(Map<String, dynamic> json) {
|
||||
final roles = (json['roles'] as Map<String, dynamic>)
|
||||
.map((id, value) => MapEntry(id, ActivityRoleModel.fromJson(value)));
|
||||
final roles = (json['roles'] as Map<String, dynamic>?)
|
||||
?.map((id, value) => MapEntry(id, ActivityRoleModel.fromJson(value)));
|
||||
|
||||
return ActivityRolesModel(
|
||||
roles,
|
||||
roles ?? {},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -235,9 +235,21 @@ class PangeaMessageEvent {
|
|||
event.content.tryGetMap(ModelKey.botTranscription);
|
||||
|
||||
if (rawBotTranscription != null) {
|
||||
return SpeechToTextModel.fromJson(
|
||||
Map<String, dynamic>.from(rawBotTranscription),
|
||||
);
|
||||
try {
|
||||
return SpeechToTextModel.fromJson(
|
||||
Map<String, dynamic>.from(rawBotTranscription),
|
||||
);
|
||||
} catch (err, s) {
|
||||
ErrorHandler.logError(
|
||||
e: err,
|
||||
s: s,
|
||||
data: {
|
||||
"event": _event.toJson(),
|
||||
},
|
||||
m: "error parsing botTranscription",
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return representations
|
||||
|
|
@ -270,9 +282,22 @@ class PangeaMessageEvent {
|
|||
final rawBotTranscription =
|
||||
event.content.tryGetMap(ModelKey.botTranscription);
|
||||
if (rawBotTranscription != null) {
|
||||
final botTranscription = SpeechToTextModel.fromJson(
|
||||
Map<String, dynamic>.from(rawBotTranscription),
|
||||
);
|
||||
SpeechToTextModel botTranscription;
|
||||
try {
|
||||
botTranscription = SpeechToTextModel.fromJson(
|
||||
Map<String, dynamic>.from(rawBotTranscription),
|
||||
);
|
||||
} catch (err, s) {
|
||||
ErrorHandler.logError(
|
||||
e: err,
|
||||
s: s,
|
||||
data: {
|
||||
"event": _event.toJson(),
|
||||
},
|
||||
m: "error parsing botTranscription",
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
_representations ??= [];
|
||||
_representations!.add(
|
||||
|
|
|
|||
|
|
@ -75,7 +75,9 @@ class LemmaReactionPicker extends StatelessWidget {
|
|||
|
||||
return LemmaEmojiPicker(
|
||||
emojis: emojis,
|
||||
onSelect: event != null ? (emoji) => setEmoji(emoji, context) : null,
|
||||
onSelect: event?.room.timeline != null
|
||||
? (emoji) => setEmoji(emoji, context)
|
||||
: null,
|
||||
disabled: (emoji) => sentReactions.contains(emoji),
|
||||
loading: loading,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -222,12 +222,17 @@ class SpeechToTextModel {
|
|||
|
||||
String get langCode => results.first.transcripts.first.langCode;
|
||||
|
||||
factory SpeechToTextModel.fromJson(Map<String, dynamic> json) =>
|
||||
SpeechToTextModel(
|
||||
results: (json['results'] as List)
|
||||
.map((e) => SpeechToTextResult.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
factory SpeechToTextModel.fromJson(Map<String, dynamic> json) {
|
||||
final results = json['results'] as List;
|
||||
if (results.isEmpty) {
|
||||
throw Exception('SpeechToTextModel.fromJson: results is empty');
|
||||
}
|
||||
return SpeechToTextModel(
|
||||
results: (json['results'] as List)
|
||||
.map((e) => SpeechToTextResult.fromJson(e))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"results": results.map((e) => e.toJson()).toList(),
|
||||
|
|
|
|||
|
|
@ -432,13 +432,14 @@ class SelectModeButtonsState extends State<SelectModeButtons> {
|
|||
|
||||
widget.overlayController.setTranscription(resp!);
|
||||
_transcriptionCompleter?.complete(resp.transcript.text);
|
||||
} catch (err) {
|
||||
} catch (err, s) {
|
||||
widget.overlayController.setTranscriptionError(
|
||||
err.toString(),
|
||||
);
|
||||
_transcriptionCompleter?.completeError(err);
|
||||
ErrorHandler.logError(
|
||||
e: err,
|
||||
s: s,
|
||||
data: {},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -385,14 +385,14 @@ class MatrixState extends State<Matrix> with WidgetsBindingObserver {
|
|||
}
|
||||
} else {
|
||||
// #Pangea
|
||||
final isL2Set = await pangeaController.userController.isUserL2Set;
|
||||
FluffyChatApp.router.go(
|
||||
state == LoginState.loggedIn
|
||||
? isL2Set
|
||||
? '/rooms'
|
||||
: '/registration/create'
|
||||
: '/home',
|
||||
);
|
||||
if (state == LoginState.loggedIn) {
|
||||
final isL2Set = await pangeaController.userController.isUserL2Set;
|
||||
FluffyChatApp.router.go(
|
||||
isL2Set ? '/rooms' : '/registration/create',
|
||||
);
|
||||
} else {
|
||||
FluffyChatApp.router.go('/home');
|
||||
}
|
||||
// FluffyChatApp.router
|
||||
// .go(state == LoginState.loggedIn ? '/rooms' : '/home');
|
||||
// Pangea#
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue