Skip to content

4xx call throws DioError which exposes implementation details #13

@JulianBissekkou

Description

@JulianBissekkou

The lib uses dio internally which forces consumers to catch the error if an unsuccessful call throws a DioError.
We currently use this helper method to map unsuccessful calls to own exception/other exception types.

// Some calls fail because Dio is used internally and this will throw instead
  // of returning a 4xx response.
  Future<R> _catchApiErrors<R>(FutureOr<R> Function() call) async {
    try {
      return await call();
    } on DioError catch (error) {
      if (error.response.statusCode == 401) {
        throw ApiException.unauthorized(); // own exception type

      }
      rethrow;
    }
  }

I just want to point out that this is not an issue atm, but it might be a nice thing to improve.
Feel free to close this issue 👍

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions