Blame view

lib/common/request/exception_handler.dart 415 Bytes
056970d8   Key   feat: api
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  import 'package:flutter_easyloading/flutter_easyloading.dart';
  
  import 'exception.dart';
  
  
  bool handleException(ApiException exception,
      {bool Function(ApiException)? onError}) {
    if (onError?.call(exception) == true) {
      return true;
    }
  
    if (exception.code == 401) {
      ///todo to login
      return true;
    }
    EasyLoading.showError(exception.message ?? ApiException.unknownException);
  
    return false;
  }