mergedWith method
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.
Implementation
@useResult
@mustBeOverridden
UserException mergedWith(UserException? anotherUserException) {
//
if (anotherUserException == null)
return this;
else {
var newReason = joinCauses(anotherUserException._msgOrCode(), anotherUserException.reason);
var mergedException = addReason(newReason);
// If any of the exceptions has ifOpenDialog `false`, the merged exception will have it too.
if (ifOpenDialog && !anotherUserException.ifOpenDialog)
mergedException = mergedException.noDialog;
// If any of the exceptions has `errorText`, the merged exception will have it too.
// If both have it, keep the one from the [anotherUserException].
if (anotherUserException.errorText?.isNotEmpty ?? false)
mergedException = mergedException.withErrorText(anotherUserException.errorText);
return mergedException;
}
}