mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 03:26:24 +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:
parent
75e0a69eab
commit
dacbf880da
3 changed files with 51 additions and 12 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue