Add is_persistent to ResultCode (#32)

This is helpful when EPP requests are executed in a loop, and you want to
know if the error result will persist for additional requests with
similar but different arguments.
This commit is contained in:
Rudi Floren 2024-01-04 19:56:01 +01:00 committed by GitHub
parent a8d9d306f3
commit 7bf527b34d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 0 deletions

View File

@ -135,6 +135,31 @@ impl ResultCode {
| CommandCompletedSuccessfullyEndingSession
)
}
/// Returns true if this error is likely to persist across similar requests inside the same
/// connection or session.
///
/// The same command with different arguments might succeed in some cases.
pub fn is_persistent(&self) -> bool {
use ResultCode::*;
match self {
// The same command with different arguments will result in the same error
UnknownCommand
| CommandSyntaxError
| RequiredParameterMissing
| ParameterValueRangeError
| ParameterValueSyntaxError
| UnimplementedProtocolVersion
| UnimplementedCommand
| UnimplementedOption
| UnimplementedExtension => true,
// The connection is in an unhealthy state
CommandFailedServerClosingConnection
| AuthenticationErrorServerClosingConnection
| SessionLimitExceededServerClosingConnection => true,
_ => false,
}
}
}
impl<'xml> FromXml<'xml> for ResultCode {