2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-15 19:55:27 +00:00

Add sentry reporting if key is used incorrectly

This commit is contained in:
Oliver Walters
2023-04-21 20:34:24 +10:00
parent 415ec259e5
commit 399d16f488

View File

@ -1,5 +1,4 @@
import "dart:async"; import "dart:async";
import "dart:convert";
import "dart:io"; import "dart:io";
import "package:font_awesome_flutter/font_awesome_flutter.dart"; import "package:font_awesome_flutter/font_awesome_flutter.dart";
@ -78,6 +77,14 @@ class InvenTreeModel {
if (subKey.isNotEmpty) { if (subKey.isNotEmpty) {
if (!data.containsKey(subKey)) { if (!data.containsKey(subKey)) {
sentryReportMessage(
"getValue() called with invalid subKey",
context: {
"model": URL,
"key": key,
"subKey": subKey
}
);
debug("JSON data does not contain subKey '$subKey' for key '$key'"); debug("JSON data does not contain subKey '$subKey' for key '$key'");
return backup; return backup;
} }
@ -88,6 +95,14 @@ class InvenTreeModel {
if (data.containsKey(key)) { if (data.containsKey(key)) {
return data[key]; return data[key];
} else { } else {
sentryReportMessage(
"getValue() called with invalid key",
context: {
"model": URL,
"key": key,
"subKey": subKey
}
);
debug("JSON data does not contain key '$key' (subKey '${subKey}')"); debug("JSON data does not contain key '$key' (subKey '${subKey}')");
return backup; return backup;
} }