ConnectionException class

The ConnectionException is a type of UserException that warns the user when the connection is not working. Use ConnectionException.noConnectivity for a simple version that warns the users they should check the connection. Use factory create to give more complete messages, indicating the host that is having problems.

Inheritance
Available Extensions

Constructors

ConnectionException({void onRetry()?, String? host, String? errorText, bool ifOpenDialog = true})
Creates a ConnectionException.
const

Properties

code int?
Optionally, instead of message we may provide a numeric code. This code may have an associated message which is set in the client.
finalinherited
errorText String?
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.
finalinherited
hardCause Object?
The hard cause is some error which caused the UserException, but that is not a UserException itself. For example: int.parse('a') throws a FormatException. Then: throw UserException('Invalid number').addCause(FormatException('Invalid input')). will have the FormatException as the hard cause. Note: If a UserException is passed as the hard cause, it will be added with addCause, and will not become the hard cause. In other words, a UserException will never be a hard cause.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
host String?
final
ifOpenDialog bool
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.
finalinherited
message String?
Some message shown to the user.
finalinherited
noDialog UserException
no setteroverride
onCancel VoidCallback?
Callback to be called after the user views the error, and taps CANCEL in the dialog.
finalinherited
onOk VoidCallback?
Callback to be called after the user views the error, and taps OK in the dialog.
finalinherited
props → IMap<String, dynamic>
The properties added to the exception, if any. They are an immutable-map of type IMap, of key-value pairs. To read the properties, use the [] operator, like this:
finalinherited
reason String?
Another text which is the reason of the user-exception.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addReason(String? reason) UserException
Returns a new UserException, copied from the current one, but adding the given reason. Note the added reason won't replace the original reason, but will be added to it.
override
mergedWith(UserException? anotherUserException) UserException
Returns a new UserException, by merging the current one with the given anotherUserException. This simply means the given anotherUserException will be used as part of the reason of the current one.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
titleAndContent() → (String, String)
Based on the message, code and reason, returns the title and content to be used in some UI to show the exception the user. The UI is usually a dialog or toast.
inherited
toString() String
A string representation of this object.
inherited
withDialog(bool ifOpenDialog) UserException
Defines if this exception should open a dialog or not. If not, it will be shown in a different way, usually showing errorText somewhere in the UI.
override
withErrorText(String? newErrorText) UserException
Adds (or replaces, if it already exists) the given newErrorText. If the newErrorText is null or empty, it will remove the errorText.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

noConnectivityWithRetry(void onRetry()?) ConnectionException
Usage: throw ConnectionException.noConnectivityWithRetry(() {...});

Constants

noConnectivity → const ConnectionException