|
|
@ -3,26 +3,41 @@ import 'package:neon/l10n/localizations.dart'; |
|
|
|
import 'package:neon/src/models/label_builder.dart'; |
|
|
|
import 'package:neon/src/models/label_builder.dart'; |
|
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
|
import 'package:permission_handler/permission_handler.dart'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Details of a [NeonException]. |
|
|
|
class NeonExceptionDetails { |
|
|
|
class NeonExceptionDetails { |
|
|
|
|
|
|
|
/// Creates new [NeonExceptionDetails]. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// [isUnauthorized] defaults to false. |
|
|
|
const NeonExceptionDetails({ |
|
|
|
const NeonExceptionDetails({ |
|
|
|
required this.getText, |
|
|
|
required this.getText, |
|
|
|
this.isUnauthorized = false, |
|
|
|
this.isUnauthorized = false, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Text that will be displayed in the UI |
|
|
|
final LabelBuilder getText; |
|
|
|
final LabelBuilder getText; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// If the [Exception] is the result of an unauthorized API request this should be set to `true`. |
|
|
|
|
|
|
|
/// |
|
|
|
|
|
|
|
/// The user will then be shown a button to update the credentials of the account instead of retrying the action. |
|
|
|
final bool isUnauthorized; |
|
|
|
final bool isUnauthorized; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Extensible [Exception] to be used for displaying custom errors in the UI |
|
|
|
@immutable |
|
|
|
@immutable |
|
|
|
abstract class NeonException implements Exception { |
|
|
|
abstract class NeonException implements Exception { |
|
|
|
|
|
|
|
/// Creates a NeonException |
|
|
|
const NeonException(); |
|
|
|
const NeonException(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Details that will be rendered by the UI |
|
|
|
NeonExceptionDetails get details; |
|
|
|
NeonExceptionDetails get details; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// [Exception] that should be thrown when a native permission is denied. |
|
|
|
class MissingPermissionException extends NeonException { |
|
|
|
class MissingPermissionException extends NeonException { |
|
|
|
|
|
|
|
/// Creates a MissingPermissionException |
|
|
|
const MissingPermissionException(this.permission); |
|
|
|
const MissingPermissionException(this.permission); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Permission that was denied |
|
|
|
final Permission permission; |
|
|
|
final Permission permission; |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|