UserExceptionAction<St> constructor
UserExceptionAction<St> (
- String? message, {
- int? code,
- String? reason,
- VoidCallback? onOk,
- VoidCallback? onCancel,
- Object? cause,
- Map<
String, dynamic> ? props, - bool ifOpenDialog = true,
- String? errorText,
Implementation
UserExceptionAction(
/// Some message shown to the user.
/// Example: `dispatch(UserExceptionAction('Invalid number'))`
String? message, {
//
/// Optionally, instead of [message] we may provide a numeric [code].
/// This code may have an associated message which is set in the client.
/// Example: `dispatch(UserExceptionAction('', code: 12))`
int? code,
/// Another message which is the reason of the user-exception.
/// Example: `dispatch(UserExceptionAction('Invalid number', reason: 'Must be less than 42'))`
String? reason,
/// Callback to be called after the user views the error and taps OK.
VoidCallback? onOk,
/// Callback to be called after the user views the error and taps CANCEL.
VoidCallback? onCancel,
/// Adds the given `cause` to the exception.
/// * If the added `cause` is a `String`, the `addReason` method will be used to
/// create the exception.
/// * If the added `cause` is a `UserException`, the `mergedWith` method will
/// be used to create the exception.
/// * If the added `cause` is any other type, including any other error types, it will be
/// set as the property `hardCause` of the exception. The hard cause is meant to be some
/// error which caused the `UserException`, but that is not a `UserException` itself.
/// For example: `dispatch(UserException('Invalid number', cause: FormatException('Invalid input'))`.
/// will set the `FormatException` as the hard cause.
Object? cause,
/// Any key-value pair properties you'd like to add to the exception.
/// For example: `props: {'name': 'John', 'age': 42}`
Map<String, dynamic>? props,
/// If `true`, the [UserExceptionDialog] will show in the dialog or similar UI.
/// If `false` you can still show the error in a different way, usually showing [errorText]
/// in the UI element that is responsible for the error.
final bool ifOpenDialog = true,
/// Some text to be displayed in the UI element that is responsible for the error.
/// For example, a text field could show this text in its `errorText` property.
/// When building your widgets, you can get the [errorText] from the failed action:
/// `String errorText = context.exceptionFor(MyAction)?.errorText`.
final String? errorText,
//
}) : this.from(
UserException(
message,
reason: reason,
code: code,
ifOpenDialog: ifOpenDialog,
errorText: errorText,
).addCause(cause).addProps(props),
);