TF-196 Create RemoteExceptionThrower to catch error from network
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
|
||||
import 'package:core/domain/exceptions/remote_exception.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class RemoteExceptionThrower {
|
||||
void throwRemoteException(dynamic exception, {Function(DioError)? handler}) {
|
||||
if (exception is DioError) {
|
||||
handler != null ? handler(exception) : throw UnknownError(exception.message);
|
||||
} else {
|
||||
throw UnknownError(exception.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user