chore: Correct runtime type checking for errors
This commit is contained in:
parent
90acab334f
commit
a2b397a7a9
1 changed files with 8 additions and 9 deletions
|
|
@ -5,7 +5,6 @@ import 'package:flutter/services.dart';
|
|||
|
||||
import 'package:flutter_highlighter/flutter_highlighter.dart';
|
||||
import 'package:flutter_highlighter/themes/shades-of-purple.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
|
@ -21,12 +20,12 @@ class ErrorReporter {
|
|||
|
||||
const ErrorReporter(this.context, [this.message]);
|
||||
|
||||
static const Set<Type> ingoredTypes = {
|
||||
IOException,
|
||||
http.ClientException,
|
||||
SocketException,
|
||||
TlsException,
|
||||
HandshakeException,
|
||||
static const Set<String> ingoredTypes = {
|
||||
"IOException",
|
||||
"ClientException",
|
||||
"SocketException",
|
||||
"TlsException",
|
||||
"HandshakeException",
|
||||
};
|
||||
|
||||
Future<File> _getTemporaryErrorLogFile() async {
|
||||
|
|
@ -38,7 +37,7 @@ class ErrorReporter {
|
|||
Object error, [
|
||||
StackTrace? stackTrace,
|
||||
]) async {
|
||||
if (ingoredTypes.contains(error.runtimeType)) return;
|
||||
if (ingoredTypes.contains(error.runtimeType.toString())) return;
|
||||
final file = await _getTemporaryErrorLogFile();
|
||||
if (await file.exists()) await file.delete();
|
||||
await file.writeAsString(
|
||||
|
|
@ -55,7 +54,7 @@ class ErrorReporter {
|
|||
}
|
||||
|
||||
void onErrorCallback(Object error, [StackTrace? stackTrace]) {
|
||||
if (ingoredTypes.contains(error.runtimeType)) return;
|
||||
if (ingoredTypes.contains(error.runtimeType.toString())) return;
|
||||
Logs().e(message ?? 'Error caught', error, stackTrace);
|
||||
final text = '$error\n${stackTrace ?? ''}';
|
||||
return _onErrorCallback(text);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue