Blame view

lib/common/request/exception_handler.dart 468 Bytes
056970d8   Key   feat: api
1
  import 'package:flutter_easyloading/flutter_easyloading.dart';
94342c3f   Key   feat: user util
2
  import 'package:wow_english/common/core/user_util.dart';
056970d8   Key   feat: api
3
4
5
  
  import 'exception.dart';
  
05f9b20a   Key   fixed: api调用方式,未完善
6
  bool handleException(ApiException exception, {bool Function(ApiException)? onError}) {
056970d8   Key   feat: api
7
8
9
10
    if (onError?.call(exception) == true) {
      return true;
    }
  
94342c3f   Key   feat: user util
11
12
    if (exception.code == 405) {
      UserUtil.logout();
056970d8   Key   feat: api
13
14
15
      return true;
    }
    EasyLoading.showError(exception.message ?? ApiException.unknownException);
056970d8   Key   feat: api
16
17
    return false;
  }