一个微型 Dart 库,提供通用的异常。
该库的目标是允许最终用户使用相同的通用 AppException 重新抛出其他库的异常。
这样就可以让所有应该被捕获的异常都继承自同一个基类。
例如,如果你想在所有未经授权的异常上显示一个 Toast 消息,这将非常有用。
这对于例如,如果你想在所有未经授权的异常上显示一个 Toast 消息,这将非常有用。
这对于例如,如果你想在所有未经授权的异常上显示一个 Toast 消息,这将非常有用。
用法
import 'package:app_exceptions/app_exceptions.dart' as ex;
void main() {
ex.AppException('Generic', 'this is a generic exception');
ex.UnauthorizedException(
description: 'You were not authorized to access this resource');
ex.InvalidInputException('email', description: 'invalid email');
ex.ActionCancelledException(
description: 'The action was canceled by the user');
ex.NotFoundException(description: 'the resource was not found');
ex.PermissionNotGrantedException(
description: 'Permission for geolocation not granted');
ex.ServiceUnavailableException(
description: 'The audio service is unavailable');
}