exception_handler.dart 468 Bytes
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:wow_english/common/core/user_util.dart';

import 'exception.dart';

bool handleException(ApiException exception, {bool Function(ApiException)? onError}) {
  if (onError?.call(exception) == true) {
    return true;
  }

  if (exception.code == 405) {
    UserUtil.logout();
    return true;
  }
  EasyLoading.showError(exception.message ?? ApiException.unknownException);
  return false;
}