Error::new("domain:characters_not_permitted","Domain name label {label} contains characters not permitted. The allowed characters are lowercase alphanumeric characters (a-z and 0-9), the dash ('-'), the underscore ('_') and the forward slash ('/').")
.with_details(json!({
"label": label
}))
},
DomainValidationError::EmptyDomain=>{
Error::new("domain:empty_domain","Domain name can not be empty or the root domain ('.')")
},
DomainValidationError::EmptyLabel=>{
Error::new("domain:empty_label","Domain name contains empty labels (repeated dots)")
},
DomainValidationError::DomainTooLong{length}=>{
Error::new("domain:domain_too_long","Domain name too long ({length} characters), the maximum length is 255 characters")
Error::new("record:txt:parse:escape_decimal_index_too_high","Octect escape sequence should be between 000 and 255. Offending escape sequence: \\{sequence}")
Error::new("record:txt:parse:escape_decimal_not_digits","Expected an octect escape sequence due to the presence of a back slash (\\) followed by a digit but found non digit characters. Offending escape sequence: \\{sequence}")
Error::new("record:txt:parse:escape_decimal_too_short","Expected an octect escape sequence due to the presence of a back slash (\\) followed by a digit but found found {sequence_lenght} characters instead of three. Offending escape sequence: \\{sequence}")
.with_details(json!({
"sequence": sequence,
"sequence_lenght": sequence.len()
}))
},
TxtParseError::MissingEscape=>{
Error::new("record:txt:parse:escape_missing","Expected an escape sequence due to the presence of a back slash (\\) at the end of the input but found nothing")
},
TxtParseError::NonAscii{character}=>{
Error::new("record:txt:parse:non_ascii","Found a non ASCII character ({character}). Only printable ASCII characters are allowed.")
.with_details(json!({
"character": character
}))
}
}
}
}
implFrom<DnsDriverError>forError{
fnfrom(value: DnsDriverError)-> Self{
matchvalue{
DnsDriverError::ConnectionError{reason}=>{
Error::new("dns:connection","Error while connecting to the name server")
.with_cause(&reason.to_string())
},
DnsDriverError::OperationError{reason}=>{
Error::new("dns:operation","DNS operation error")
.with_cause(&reason.to_string())
},
DnsDriverError::ServerError{rcode,name,qtype}=>{
Error::new("dns:server","Unexpected response to query")
.with_details(json!({
"rcode": rcode,
"name": name,
"qtype": qtype,
}))
},
DnsDriverError::ZoneNotFound{name}=>{
Error::new("dns:zone_not_found","The zone {zone_name} does not exist on the name server")
.with_details(json!({
"zone_name": name
}))
}
}
}
}
implFrom<RecordParseError>forError{
fnfrom(value: RecordParseError)-> Self{
matchvalue{
RecordParseError::Ip4Address{input}=>{
Error::new("record:parse:ip4","The following IPv4 address {input} is invalid. IPv4 addresses should have four numbers, each between 0 and 255, separated by dots.")
.with_details(json!({
"input": input
}))
},
RecordParseError::Ip6Address{input}=>{
Error::new("record:parse:ip6","The following IPv4 address {input} is invalid. IPv6 addresses should have eight groups of four hexadecimal digit separated by colons. Leftmost zeros in a group can be omitted, sequence of zeros can be shorted by a double colons.")