catch null _choreo and _event earlier in flow, switch from error to warning
This commit is contained in:
parent
9501f6f964
commit
a2fb362bde
2 changed files with 34 additions and 24 deletions
|
|
@ -14,6 +14,7 @@ import 'package:fluffychat/pangea/utils/bot_name.dart';
|
|||
import 'package:fluffychat/pangea/widgets/chat/message_audio_card.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
||||
|
||||
import '../../widgets/matrix.dart';
|
||||
import '../constants/language_keys.dart';
|
||||
|
|
@ -270,32 +271,41 @@ class PangeaMessageEvent {
|
|||
List<RepresentationEvent>? _representations;
|
||||
List<RepresentationEvent> get representations {
|
||||
if (_representations != null) return _representations!;
|
||||
|
||||
_representations = [];
|
||||
|
||||
if (_latestEdit.content[ModelKey.originalSent] != null) {
|
||||
try {
|
||||
_representations!.add(
|
||||
RepresentationEvent(
|
||||
content: PangeaRepresentation.fromJson(
|
||||
_latestEdit.content[ModelKey.originalSent]
|
||||
as Map<String, dynamic>,
|
||||
),
|
||||
tokens: _latestEdit.content[ModelKey.tokensSent] != null
|
||||
? PangeaMessageTokens.fromJson(
|
||||
_latestEdit.content[ModelKey.tokensSent]
|
||||
as Map<String, dynamic>,
|
||||
)
|
||||
: null,
|
||||
choreo: _latestEdit.content[ModelKey.choreoRecord] != null
|
||||
? ChoreoRecord.fromJson(
|
||||
_latestEdit.content[ModelKey.choreoRecord]
|
||||
as Map<String, dynamic>,
|
||||
)
|
||||
: null,
|
||||
timeline: timeline,
|
||||
final RepresentationEvent sent = RepresentationEvent(
|
||||
content: PangeaRepresentation.fromJson(
|
||||
_latestEdit.content[ModelKey.originalSent] as Map<String, dynamic>,
|
||||
),
|
||||
tokens: _latestEdit.content[ModelKey.tokensSent] != null
|
||||
? PangeaMessageTokens.fromJson(
|
||||
_latestEdit.content[ModelKey.tokensSent]
|
||||
as Map<String, dynamic>,
|
||||
)
|
||||
: null,
|
||||
choreo: _latestEdit.content[ModelKey.choreoRecord] != null
|
||||
? ChoreoRecord.fromJson(
|
||||
_latestEdit.content[ModelKey.choreoRecord]
|
||||
as Map<String, dynamic>,
|
||||
)
|
||||
: null,
|
||||
timeline: timeline,
|
||||
);
|
||||
if (_latestEdit.content[ModelKey.choreoRecord] == null) {
|
||||
Sentry.addBreadcrumb(
|
||||
Breadcrumb(
|
||||
message: "originalSent created without _event or _choreo",
|
||||
data: {
|
||||
"eventId": _latestEdit.eventId,
|
||||
"room": _latestEdit.room.id,
|
||||
"sender": _latestEdit.senderId,
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
_representations!.add(sent);
|
||||
} catch (err, s) {
|
||||
ErrorHandler.logError(
|
||||
m: "error parsing originalSent",
|
||||
|
|
|
|||
|
|
@ -136,10 +136,10 @@ class RepresentationEvent {
|
|||
if (_choreo != null) return _choreo;
|
||||
|
||||
if (_event == null) {
|
||||
// debugger(when: kDebugMode);
|
||||
ErrorHandler.logError(
|
||||
m: '_event and _choreo both null',
|
||||
s: StackTrace.current,
|
||||
Sentry.addBreadcrumb(
|
||||
Breadcrumb(
|
||||
message: "_event and _choreo both null",
|
||||
),
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue