2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-16 20:25:26 +00:00

Improve error handling and reporting (#190)

* Prevent duplicate reporting of errors to sentry

* Prevent error message upload on some server error codes

* Filter out some common errors we are not interested in
This commit is contained in:
Oliver
2022-07-26 15:57:16 +10:00
committed by GitHub
parent 75e0a69eab
commit dacbf880da
3 changed files with 51 additions and 12 deletions

View File

@ -234,10 +234,23 @@ class InvenTreeModel {
return {};
}
/*
* Report error information to sentry, when a model operation fails.
*/
Future<void> reportModelError(String title, APIResponse response, {Map<String, String> context = const {}}) async {
String dataString = response.data?.toString() ?? "null";
// If the response has "errorDetail" set, then the error has already been handled, and there is no need to continue
if (response.errorDetail.isNotEmpty) {
return;
}
// If the response status code indicates a server error, then this has already been reported
if (response.statusCode >= 500) {
return;
}
if (dataString.length > 500) {
dataString = dataString.substring(0, 500);
}