reporting: privent noisy reports
This commit is contained in:
parent
2e13879d77
commit
55e8427e3d
5 changed files with 15 additions and 14 deletions
|
@ -1,6 +1,7 @@
|
|||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:aves/services/common/services.dart';
|
||||
import 'package:aves_report/aves_report.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
@ -46,14 +47,14 @@ class ThumbnailProvider extends ImageProvider<ThumbnailProviderKey> {
|
|||
taskKey: key,
|
||||
);
|
||||
if (bytes.isEmpty) {
|
||||
throw StateError('$uri ($mimeType) loading failed');
|
||||
throw UnreportedStateError('$uri ($mimeType) loading failed');
|
||||
}
|
||||
final buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
|
||||
return await decode(buffer);
|
||||
} catch (error) {
|
||||
// loading may fail if the provided MIME type is incorrect (e.g. the Media Store may report a JPEG as a TIFF)
|
||||
debugPrint('$runtimeType _loadAsync failed with mimeType=$mimeType, uri=$uri, error=$error');
|
||||
throw StateError('$mimeType decoding failed (page $pageId)');
|
||||
throw UnreportedStateError('$mimeType decoding failed (page $pageId)');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
|||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:aves/services/common/services.dart';
|
||||
import 'package:aves_report/aves_report.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
@ -64,14 +65,14 @@ class UriImage extends ImageProvider<UriImage> with EquatableMixin {
|
|||
},
|
||||
);
|
||||
if (bytes.isEmpty) {
|
||||
throw StateError('$uri ($mimeType) loading failed');
|
||||
throw UnreportedStateError('$uri ($mimeType) loading failed');
|
||||
}
|
||||
final buffer = await ui.ImmutableBuffer.fromUint8List(bytes);
|
||||
return await decode(buffer);
|
||||
} catch (error) {
|
||||
// loading may fail if the provided MIME type is incorrect (e.g. the Media Store may report a JPEG as a TIFF)
|
||||
debugPrint('$runtimeType _loadAsync failed with mimeType=$mimeType, uri=$uri, error=$error');
|
||||
throw StateError('$mimeType decoding failed (page $pageId)');
|
||||
throw UnreportedStateError('$mimeType decoding failed (page $pageId)');
|
||||
} finally {
|
||||
unawaited(chunkEvents.close());
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:aves/services/common/services.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
@ -22,14 +21,8 @@ class GeocodingService {
|
|||
'maxResults': 2,
|
||||
});
|
||||
return (result as List).cast<Map>().map(Address.fromMap).toList();
|
||||
} on PlatformException catch (e, stack) {
|
||||
if (!{
|
||||
'getAddress-empty',
|
||||
'getAddress-network',
|
||||
'getAddress-unavailable',
|
||||
}.contains(e.code)) {
|
||||
await reportService.recordError(e, stack);
|
||||
}
|
||||
} on PlatformException catch (_) {
|
||||
// do not report
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -35,3 +35,7 @@ abstract class ReportService {
|
|||
.join('\n'));
|
||||
}
|
||||
}
|
||||
|
||||
class UnreportedStateError extends StateError {
|
||||
UnreportedStateError(super.message);
|
||||
}
|
|
@ -71,8 +71,10 @@ class PlatformReportService extends ReportService {
|
|||
if (exception is PlatformException && stack != null) {
|
||||
stack = ReportService.buildReportStack(stack, level: 2);
|
||||
}
|
||||
if (exception! is UnreportedStateError) {
|
||||
return _instance?.recordError(exception, stack);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> recordFlutterError(FlutterErrorDetails flutterErrorDetails) async {
|
||||
|
|
Loading…
Reference in a new issue