-
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
73 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 12 additions & 8 deletions
20
dart/lib/src/dart_error_type_identifier.dart → ...b/src/dart_exception_type_identifier.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
import '../sentry.dart'; | ||
|
||
class DartErrorIdentifier implements ErrorTypeIdentifier { | ||
class DartExceptionTypeIdentifier implements ExceptionTypeIdentifier { | ||
@override | ||
String? getTypeName(dynamic error) { | ||
if (error is NoSuchMethodError) return 'NoSuchMethodError'; | ||
if (error is FormatException) return 'FormatException'; | ||
if (error is TypeError) return 'TypeError'; | ||
String? identifyType(dynamic error) { | ||
if (error is ArgumentError) return 'ArgumentError'; | ||
if (error is StateError) return 'StateError'; | ||
if (error is UnsupportedError) return 'UnsupportedError'; | ||
if (error is UnimplementedError) return 'UnimplementedError'; | ||
if (error is AssertionError) return 'AssertionError'; | ||
if (error is ConcurrentModificationError) | ||
return 'ConcurrentModificationError'; | ||
Check notice on line 9 in dart/lib/src/dart_exception_type_identifier.dart GitHub Actions / analyze / analyzeStatements in an if should be enclosed in a block.
|
||
if (error is FormatException) return 'FormatException'; | ||
if (error is IndexError) return 'IndexError'; | ||
if (error is NoSuchMethodError) return 'NoSuchMethodError'; | ||
if (error is OutOfMemoryError) return 'OutOfMemoryError'; | ||
if (error is RangeError) return 'RangeError'; | ||
if (error is StackOverflowError) return 'StackOverflowError'; | ||
if (error is StateError) return 'StateError'; | ||
if (error is TypeError) return 'TypeError'; | ||
if (error is UnimplementedError) return 'UnimplementedError'; | ||
if (error is UnsupportedError) return 'UnsupportedError'; | ||
// we purposefully don't include Exception or Error since it's too generic | ||
return null; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/// An abstract class for identifying the type of Dart errors and exceptions. | ||
/// | ||
/// This class provides a contract for implementing error type identification | ||
/// in Dart. It's used in scenarios where error types need to be | ||
/// determined in obfuscated builds, as [runtimeType] is not reliable in | ||
/// such cases. | ||
/// | ||
/// Implement this class to create custom error type identifiers for errors or exceptions. | ||
/// that we do not support out of the box. | ||
/// | ||
/// Add the implementation using [SentryOptions.addExceptionTypeIdentifier]. | ||
/// | ||
/// Example: | ||
/// ```dart | ||
/// class MyErrorTypeIdentifier implements ErrorTypeIdentifier { | ||
/// @override | ||
/// String? identifyType(dynamic error) { | ||
/// if (error is MyCustomError) return 'MyCustomError'; | ||
/// return null; | ||
/// } | ||
/// } | ||
/// ``` | ||
abstract class ExceptionTypeIdentifier { | ||
String? identifyType(dynamic throwable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/cupertino.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
import '../sentry_flutter.dart'; | ||
|
||
class FlutterErrorIdentifier implements ErrorTypeIdentifier { | ||
class FlutterExceptionTypeIdentifier implements ExceptionTypeIdentifier { | ||
@override | ||
String? getTypeName(dynamic error) { | ||
if (error is FlutterError) return 'FlutterError'; | ||
if (error is PlatformException) return 'PlatformException'; | ||
if (error is MissingPluginException) return 'MissingPluginException'; | ||
if (error is AssertionError) return 'AssertionError'; | ||
if (error is NetworkImageLoadException) return 'NetworkImageLoadException'; | ||
if (error is TickerCanceled) return 'TickerCanceled'; | ||
String? identifyType(dynamic throwable) { | ||
if (throwable is FlutterError) return 'FlutterError'; | ||
if (throwable is PlatformException) return 'PlatformException'; | ||
if (throwable is MissingPluginException) return 'MissingPluginException'; | ||
if (throwable is AssertionError) return 'AssertionError'; | ||
if (throwable is NetworkImageLoadException) | ||
return 'NetworkImageLoadException'; | ||
Check notice on line 17 in flutter/lib/src/flutter_error_type_identifier.dart GitHub Actions / analyze / analyzeStatements in an if should be enclosed in a block.
|
||
if (throwable is TickerCanceled) return 'TickerCanceled'; | ||
|
||
// dart:io Exceptions | ||
if (!kIsWeb) { | ||
if (throwable is FileSystemException) return 'FileSystemException'; | ||
if (throwable is HttpException) return 'HttpException'; | ||
if (throwable is SocketException) return 'SocketException'; | ||
if (throwable is HandshakeException) return 'HandshakeException'; | ||
if (throwable is CertificateException) return 'CertificateException'; | ||
// not adding TlsException and IOException because it's too generic | ||
} | ||
return null; | ||
} | ||
} | ||
|
||
bool isSubtype<S, T>() => <S>[] is List<T>; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters