addReason method
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.
Implementation
@useResult
@mustBeOverridden
UserException addReason(String? reason) {
//
if (reason == null)
return this;
else {
if (_ifHasMsgOrCode()) {
return UserException(
message,
code: code,
reason: joinCauses(this.reason, reason),
ifOpenDialog: ifOpenDialog,
errorText: errorText,
);
} else if (this.reason != null && this.reason!.isNotEmpty)
return UserException(
this.reason,
reason: reason,
ifOpenDialog: ifOpenDialog,
errorText: errorText,
);
else
return UserException(
reason,
ifOpenDialog: ifOpenDialog,
errorText: errorText,
);
}
}