SupaDioException extension

Extension on DioException that provides convenient HTTP status code checks.

This extension adds boolean getters to easily identify common HTTP error responses without manually checking status codes throughout the application.

Usage Example:

try {
  await dio.get('/api/endpoint');
} catch (e) {
  if (e is DioException) {
    if (e.isUnauthorized) {
      // Handle 401 error
    } else if (e.isForbidden) {
      // Handle 403 error
    }
  }
}
on
  • DioException

Properties

isBadRequest bool

Available on DioException, provided by the SupaDioException extension

Returns true if the response status code is 400 (Bad Request).
no setter
isForbidden bool

Available on DioException, provided by the SupaDioException extension

Returns true if the response status code is 403 (Forbidden).
no setter
isNotFound bool

Available on DioException, provided by the SupaDioException extension

Returns true if the response status code is 404 (Not Found).
no setter
isUnauthorized bool

Available on DioException, provided by the SupaDioException extension

Returns true if the response status code is 401 (Unauthorized).
no setter