|
| 1 | +import 'dart:io'; |
| 2 | + |
| 3 | +import 'package:http/http.dart'; |
| 4 | +import 'dart:async'; |
| 5 | + |
1 | 6 | import '../sentry.dart'; |
2 | 7 |
|
3 | 8 | class DartExceptionTypeIdentifier implements ExceptionTypeIdentifier { |
4 | 9 | @override |
5 | | - String? identifyType(dynamic error) { |
6 | | - if (error is ArgumentError) return 'ArgumentError'; |
7 | | - if (error is AssertionError) return 'AssertionError'; |
8 | | - if (error is ConcurrentModificationError) |
| 10 | + String? identifyType(dynamic throwable) { |
| 11 | + // dart:core |
| 12 | + if (throwable is ArgumentError) return 'ArgumentError'; |
| 13 | + if (throwable is AssertionError) return 'AssertionError'; |
| 14 | + if (throwable is ConcurrentModificationError) |
9 | 15 | return 'ConcurrentModificationError'; |
10 | | - if (error is FormatException) return 'FormatException'; |
11 | | - if (error is IndexError) return 'IndexError'; |
12 | | - if (error is NoSuchMethodError) return 'NoSuchMethodError'; |
13 | | - if (error is OutOfMemoryError) return 'OutOfMemoryError'; |
14 | | - if (error is RangeError) return 'RangeError'; |
15 | | - if (error is StackOverflowError) return 'StackOverflowError'; |
16 | | - if (error is StateError) return 'StateError'; |
17 | | - if (error is TypeError) return 'TypeError'; |
18 | | - if (error is UnimplementedError) return 'UnimplementedError'; |
19 | | - if (error is UnsupportedError) return 'UnsupportedError'; |
20 | | - // we purposefully don't include Exception or Error since it's too generic |
| 16 | + if (throwable is FormatException) return 'FormatException'; |
| 17 | + if (throwable is IndexError) return 'IndexError'; |
| 18 | + if (throwable is NoSuchMethodError) return 'NoSuchMethodError'; |
| 19 | + if (throwable is OutOfMemoryError) return 'OutOfMemoryError'; |
| 20 | + if (throwable is RangeError) return 'RangeError'; |
| 21 | + if (throwable is StackOverflowError) return 'StackOverflowError'; |
| 22 | + if (throwable is StateError) return 'StateError'; |
| 23 | + if (throwable is TypeError) return 'TypeError'; |
| 24 | + if (throwable is UnimplementedError) return 'UnimplementedError'; |
| 25 | + if (throwable is UnsupportedError) return 'UnsupportedError'; |
| 26 | + // not adding Exception or Error because it's too generic |
| 27 | + |
| 28 | + // dart:async |
| 29 | + if (throwable is TimeoutException) return 'TimeoutException'; |
| 30 | + if (throwable is AsyncError) return 'FutureTimeout'; |
| 31 | + if (throwable is DeferredLoadException) return 'DeferredLoadException'; |
| 32 | + // not adding ParallelWaitError because it's not supported in dart 2.17.0 |
| 33 | + |
| 34 | + // dart:io |
| 35 | + if (throwable is FileSystemException) return 'FileSystemException'; |
| 36 | + if (throwable is HttpException) return 'HttpException'; |
| 37 | + if (throwable is SocketException) return 'SocketException'; |
| 38 | + if (throwable is HandshakeException) return 'HandshakeException'; |
| 39 | + if (throwable is CertificateException) return 'CertificateException'; |
| 40 | + if (throwable is TlsException) return 'TlsException'; |
| 41 | + // not adding IOException because it's too generic |
| 42 | + |
| 43 | + // dart http package |
| 44 | + if (throwable is ClientException) return 'ClientException'; |
| 45 | + |
21 | 46 | return null; |
22 | 47 | } |
23 | 48 | } |
0 commit comments