VB10 / vexana

Vexana is network manager project with dio.
https://pub.dev/packages/vexana
MIT License
147 stars 42 forks source link

Refactor NetworkManagerErrorInterceptor to handle null onResponseParse #100

Closed aligconnectinno closed 3 months ago

aligconnectinno commented 3 months ago

Null check fix on NetworkManagerErrorInterceptor

What is the current behavior?

The code calls the onResponseParse callback function from the parameters object without null check.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

final class TempNetworkManager extends NetworkManager<EmptyModel> {
  TempNetworkManager()
      : super(
          options: BaseOptions(baseUrl: 'baseUrl'),
          onRefreshToken: (exception, _) async {
            final idToken = _getToken();
            exception.requestOptions.headers['Authorization'] = idToken;
            return exception;
          },
          // Below code not passed.
          // onReply: (response) => response,
        );

  static String _getToken() => 'Token';

What is the expected behavior?

  1. It checks if the onResponseParse callback in the parameters object is null.
  2. If onResponseParse is null, it resolves the response using handler.resolve(response).
  3. if onResponseParse is not null, it calls the onResponseParse callback with the response and then resolves the response using handler.resolve(parameters.onResponseParse!(response)).
MehmetKaranlik commented 3 months ago

Eline sağlık @aligconnectinno

VB10 commented 3 months ago

it is merged. thanks cc: @MehmetKaranlik