LCOV - code coverage report
Current view: top level - Users/duwen/Documents/code/dio/dio/lib/src - dio_error.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 9 11 81.8 %
Date: 2021-11-28 14:37:50 Functions: 0 0 -

          Line data    Source code
       1             : import 'options.dart';
       2             : import 'response.dart';
       3             : 
       4          12 : enum DioErrorType {
       5             :   /// It occurs when url is opened timeout.
       6             :   connectTimeout,
       7             : 
       8             :   /// It occurs when url is sent timeout.
       9             :   sendTimeout,
      10             : 
      11             :   ///It occurs when receiving timeout.
      12             :   receiveTimeout,
      13             : 
      14             :   /// When the server response, but with a incorrect status, such as 404, 503...
      15             :   response,
      16             : 
      17             :   /// When the request is cancelled, dio will throw a error with this type.
      18             :   cancel,
      19             : 
      20             :   /// Default error type, Some other Error. In this case, you can
      21             :   /// use the DioError.error if it is not null.
      22             :   other,
      23             : }
      24             : 
      25             : /// DioError describes the error info  when request failed.
      26             : class DioError implements Exception {
      27           6 :   DioError({
      28             :     required this.requestOptions,
      29             :     this.response,
      30             :     this.type = DioErrorType.other,
      31             :     this.error,
      32             :   });
      33             : 
      34             :   /// Request info.
      35             :   RequestOptions requestOptions;
      36             : 
      37             :   /// Response info, it may be `null` if the request can't reach to
      38             :   /// the http server, for example, occurring a dns error, network is not available.
      39             :   Response? response;
      40             : 
      41             :   DioErrorType type;
      42             : 
      43             :   /// The original error/exception object; It's usually not null when `type`
      44             :   /// is DioErrorType.other
      45             :   dynamic error;
      46             : 
      47             :   StackTrace? _stackTrace;
      48             : 
      49          12 :   set stackTrace(StackTrace? stack) => _stackTrace = stack;
      50             : 
      51          12 :   StackTrace? get stackTrace => _stackTrace;
      52             : 
      53           6 :   String get message => (error?.toString() ?? '');
      54             : 
      55           1 :   @override
      56             :   String toString() {
      57           3 :     var msg = 'DioError [$type]: $message';
      58           2 :     if (error is Error) {
      59           0 :       msg += '\n${(error as Error).stackTrace}';
      60             :     }
      61           1 :     if (_stackTrace != null) {
      62           0 :       msg += '\nSource stack:\n$stackTrace';
      63             :     }
      64             :     return msg;
      65             :   }
      66             : }

Generated by: LCOV version 1.14