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:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user