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/flutter_highlighter.dart';
|
||||||
import 'package:flutter_highlighter/themes/shades-of-purple.dart';
|
import 'package:flutter_highlighter/themes/shades-of-purple.dart';
|
||||||
import 'package:http/http.dart' as http;
|
|
||||||
import 'package:matrix/matrix.dart';
|
import 'package:matrix/matrix.dart';
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
@ -21,12 +20,12 @@ class ErrorReporter {
|
||||||
|
|
||||||
const ErrorReporter(this.context, [this.message]);
|
const ErrorReporter(this.context, [this.message]);
|
||||||
|
|
||||||
static const Set<Type> ingoredTypes = {
|
static const Set<String> ingoredTypes = {
|
||||||
IOException,
|
"IOException",
|
||||||
http.ClientException,
|
"ClientException",
|
||||||
SocketException,
|
"SocketException",
|
||||||
TlsException,
|
"TlsException",
|
||||||
HandshakeException,
|
"HandshakeException",
|
||||||
};
|
};
|
||||||
|
|
||||||
Future<File> _getTemporaryErrorLogFile() async {
|
Future<File> _getTemporaryErrorLogFile() async {
|
||||||
|
|
@ -38,7 +37,7 @@ class ErrorReporter {
|
||||||
Object error, [
|
Object error, [
|
||||||
StackTrace? stackTrace,
|
StackTrace? stackTrace,
|
||||||
]) async {
|
]) async {
|
||||||
if (ingoredTypes.contains(error.runtimeType)) return;
|
if (ingoredTypes.contains(error.runtimeType.toString())) return;
|
||||||
final file = await _getTemporaryErrorLogFile();
|
final file = await _getTemporaryErrorLogFile();
|
||||||
if (await file.exists()) await file.delete();
|
if (await file.exists()) await file.delete();
|
||||||
await file.writeAsString(
|
await file.writeAsString(
|
||||||
|
|
@ -55,7 +54,7 @@ class ErrorReporter {
|
||||||
}
|
}
|
||||||
|
|
||||||
void onErrorCallback(Object error, [StackTrace? stackTrace]) {
|
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);
|
Logs().e(message ?? 'Error caught', error, stackTrace);
|
||||||
final text = '$error\n${stackTrace ?? ''}';
|
final text = '$error\n${stackTrace ?? ''}';
|
||||||
return _onErrorCallback(text);
|
return _onErrorCallback(text);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue