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