Skip to content

Commit b044c53

Browse files
More debug (#405)
* Extra options for sentry * Use string comparison * Catch error when constructing related field * Include field name in debug
1 parent 2e2e964 commit b044c53

File tree

3 files changed

+42
-20
lines changed

3 files changed

+42
-20
lines changed

assets/release_notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Enable label printing for stock locations
55
- Enable label printing for parts
66
- Updated translation support
7+
- Bug files
78

89
### 0.12.5 - July 2023
910
---

lib/api_form.dart

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ class APIFormField {
513513
isFilterOnline: true,
514514
showSearchBox: true,
515515
itemBuilder: (context, item, isSelected) {
516-
return _renderRelatedField(item, isSelected, true);
516+
return _renderRelatedField(name, item, isSelected, true);
517517
},
518518
emptyBuilder: (context, item) {
519519
return _renderEmptyResult();
@@ -566,7 +566,7 @@ class APIFormField {
566566
}
567567
},
568568
dropdownBuilder: (context, item) {
569-
return _renderRelatedField(item, true, false);
569+
return _renderRelatedField(name, item, true, false);
570570
},
571571
onSaved: (item) {
572572
if (item != null) {
@@ -582,15 +582,32 @@ class APIFormField {
582582
return false;
583583
}
584584

585-
return item["pk"] == selectedItem["pk"];
585+
return item["pk"].toString() == selectedItem["pk"].toString();
586586
});
587587
}
588588

589589
// Render a "related field" based on the "model" type
590-
Widget _renderRelatedField(dynamic item, bool selected, bool extended) {
590+
Widget _renderRelatedField(String fieldName, dynamic item, bool selected, bool extended) {
591591

592592
// Convert to JSON
593-
var data = Map<String, dynamic>.from((item ?? {}) as Map);
593+
Map<String, dynamic> data = {};
594+
595+
try {
596+
data = Map<String, dynamic>.from((item ?? {}) as Map);
597+
} catch (error, stackTrace) {
598+
data = {};
599+
600+
sentryReportError(
601+
"_renderRelatedField", error, stackTrace,
602+
context: {
603+
"method": "_renderRelateField",
604+
"field_name": fieldName,
605+
"item": item.toString(),
606+
"selected": selected.toString(),
607+
"extended": extended.toString(),
608+
}
609+
);
610+
}
594611

595612
switch (model) {
596613
case "part":
@@ -599,7 +616,7 @@ class APIFormField {
599616

600617
return ListTile(
601618
title: Text(
602-
part.fullname,
619+
part.fullname,
603620
style: TextStyle(fontWeight: selected && extended ? FontWeight.bold : FontWeight.normal)
604621
),
605622
subtitle: extended ? Text(
@@ -615,8 +632,8 @@ class APIFormField {
615632

616633
return ListTile(
617634
title: Text(
618-
cat.pathstring,
619-
style: TextStyle(fontWeight: selected && extended ? FontWeight.bold : FontWeight.normal)
635+
cat.pathstring,
636+
style: TextStyle(fontWeight: selected && extended ? FontWeight.bold : FontWeight.normal)
620637
),
621638
subtitle: extended ? Text(
622639
cat.description,
@@ -629,7 +646,7 @@ class APIFormField {
629646

630647
return ListTile(
631648
title: Text(
632-
loc.pathstring,
649+
loc.pathstring,
633650
style: TextStyle(fontWeight: selected && extended ? FontWeight.bold : FontWeight.normal)
634651
),
635652
subtitle: extended ? Text(
@@ -654,25 +671,25 @@ class APIFormField {
654671
case "company":
655672
var company = InvenTreeCompany.fromJson(data);
656673
return ListTile(
657-
title: Text(company.name),
658-
subtitle: extended ? Text(company.description) : null,
659-
leading: InvenTreeAPI().getThumbnail(company.thumbnail)
674+
title: Text(company.name),
675+
subtitle: extended ? Text(company.description) : null,
676+
leading: InvenTreeAPI().getThumbnail(company.thumbnail)
660677
);
661678
case "projectcode":
662679
var project_code = InvenTreeProjectCode.fromJson(data);
663680
return ListTile(
664-
title: Text(project_code.code),
665-
subtitle: Text(project_code.description),
666-
leading: FaIcon(FontAwesomeIcons.list)
681+
title: Text(project_code.code),
682+
subtitle: Text(project_code.description),
683+
leading: FaIcon(FontAwesomeIcons.list)
667684
);
668685
default:
669686
return ListTile(
670687
title: Text(
671-
"Unsupported model",
672-
style: TextStyle(
673-
fontWeight: FontWeight.bold,
674-
color: COLOR_DANGER
675-
)
688+
"Unsupported model",
689+
style: TextStyle(
690+
fontWeight: FontWeight.bold,
691+
color: COLOR_DANGER
692+
)
676693
),
677694
subtitle: Text("Model '${model}' rendering not supported"),
678695
);

pubspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,7 @@ flutter:
7070
- assets/sounds/barcode_scan.mp3
7171
- assets/sounds/barcode_error.mp3
7272
- assets/sounds/server_error.mp3
73+
74+
sentry:
75+
upload_debug_symbols: true
76+
upload_source_maps: true

0 commit comments

Comments
 (0)