enaklo-flutter/lib/common/api/interceptors/unauthorized_interceptor.dart

16 lines
450 B
Dart
Raw Normal View History

2025-08-27 12:43:25 +07:00
import 'package:dio/dio.dart';
import '../errors/unauthorized_error.dart';
class UnauthorizedInterceptor extends Interceptor {
@override
void onError(DioException err, ErrorInterceptorHandler handler) {
if (err.response?.statusCode == 401 ||
err.response?.statusCode == 403 ||
err.response?.statusCode == 419) {
return super.onError(UnauthorizedError(err, null), handler);
}
super.onError(err, handler);
}
}