pub struct Error(/* private fields */);Expand description
The error of every function of the crate that can fail, and of the bindings that are built on it.
kind is what a caller matches on. Display says what is wrong, in
the words of the specification where it has them, then why, and for octets that do
not decode the field of the bindings where the decoding stopped:
use oxirush_aper::{ErrorKind, Reader};
// A number of the constraint (0..65535) is two octets, and one is there
let error = Reader::new(&[0x12]).unsigned(0, 65535).unwrap_err();
assert_eq!(error.kind(), ErrorKind::Decode);
assert_eq!(
error.to_string(),
"the octets do not decode: the octets end before the value does"
);Two errors are equal when they have the same kind and the same message. An error is
one pointer, so that a Result of a small value stays small.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(kind: ErrorKind, what: impl Into<String>) -> Self
pub fn new(kind: ErrorKind, what: impl Into<String>) -> Self
An error of a kind, which says what is wrong.
Sourcepub fn because(self, why: impl Into<String>) -> Self
pub fn because(self, why: impl Into<String>) -> Self
The same error, with the reason of what is wrong, which the message has after it.
Sourcepub fn of(self, what: impl Into<String>) -> Self
pub fn of(self, what: impl Into<String>) -> Self
The same error, told of what: what it said is wrong becomes the reason, where
it gave none apart.
Sourcepub fn ie(&self) -> Option<ErrorIe>
pub fn ie(&self) -> Option<ErrorIe>
The IE of a message that the error is about, when it is about one: an error of
the kind MissingIe or UndecodableIe that the bindings of a protocol made.
use oxirush_aper::{Criticality, Error, ErrorIe};
// The IE 21 of an NG SETUP REQUEST, received with the criticality `ignore`
let ie = ErrorIe::new(21, Criticality::Ignore, Some(3));
let error = Error::undecodable("the DefaultPagingDRX does not decode").about_ie(ie);
assert_eq!(error.ie(), Some(ie));
assert_eq!(Error::argument("an MCC has three digits").ie(), None);Sourcepub fn reworded(self, reword: impl FnOnce(&str) -> String) -> Self
pub fn reworded(self, reword: impl FnOnce(&str) -> String) -> Self
The same error, with the message that reword makes of the one that it has.
Sourcepub fn reason(&self) -> String
pub fn reason(&self) -> String
The reason of what is wrong, where the message has one apart, and what is wrong otherwise, with the field of the bindings where a decoding stopped.
Sourcepub fn fields(&self) -> impl Iterator<Item = &'static str> + '_
pub fn fields(&self) -> impl Iterator<Item = &'static str> + '_
The fields of the bindings on the way to where a decoding stopped, the outermost first: none for an error that is no decoding error, or that stopped in no field.
Sourcepub fn in_field(self, name: &'static str) -> Self
pub fn in_field(self, name: &'static str) -> Self
The same error, which was met in the field name of the bindings. A decoder of a
SEQUENCE names the member that did not decode.
Source§impl Error
The errors that the bindings of an application protocol make of a PDU, of its message
and of its IEs, in one wording for every protocol. A program that uses bindings
matches on the kind of their errors, and makes none of these.
impl Error
The errors that the bindings of an application protocol make of a PDU, of its message
and of its IEs, in one wording for every protocol. A program that uses bindings
matches on the kind of their errors, and makes none of these.
Sourcepub fn wrong_message(
expected: &str,
held: Option<&str>,
direction: &str,
code: u8,
) -> Self
pub fn wrong_message( expected: &str, held: Option<&str>, direction: &str, code: u8, ) -> Self
A PDU of another message than the one that ASN.1 names expected: held is the
name of the message of its direction and of the procedure code, when the
specification has one.
Sourcepub fn no_protocol_ies(name: &str) -> Self
pub fn no_protocol_ies(name: &str) -> Self
A PDU of the message that ASN.1 names name, which has no container of
protocol IEs.
Sourcepub fn no_message_of(direction: &str, code: u8) -> Self
pub fn no_message_of(direction: &str, code: u8) -> Self
A PDU whose direction and procedure code the specification has no message for, and so no object set.
Sourcepub fn of_message(self, name: Option<&str>) -> Self
pub fn of_message(self, name: Option<&str>) -> Self
This error is why the message of a PDU does not decode as a container of
protocol IEs: the message that ASN.1 names name, when the specification has
one for the PDU.
Sourcepub fn of_protocol_ies(self, count: usize) -> Self
pub fn of_protocol_ies(self, count: usize) -> Self
This error is why count protocol IEs do not encode as a message.
Sourcepub fn missing_ie(message: &str, ie: &str, field: &str) -> Self
pub fn missing_ie(message: &str, ie: &str, field: &str) -> Self
The IE that a message names ie, which the field field requires, is not in a
message of the type message.
use oxirush_aper::{Error, ErrorKind};
let error = Error::missing_ie("NGSetupRequest", "SupportedTAList", "areas");
assert_eq!(error.kind(), ErrorKind::MissingIe);
assert_eq!(
error.to_string(),
"this NGSetupRequest has no SupportedTAList, which the field `areas` requires"
);Sourcepub fn undecodable_ie(self, message: &str, ie: &str) -> Self
pub fn undecodable_ie(self, message: &str, ie: &str) -> Self
This error is why the IE that a message names ie does not decode, in a message
of the type message.
use oxirush_aper::{ErrorKind, Reader};
// An ENUMERATED of four values and an extension marker, read from no octet
let codec = Reader::new(&[]).enumerated(4, 0, true).unwrap_err();
let error = codec.undecodable_ie("NGSetupRequest", "DefaultPagingDRX");
assert_eq!(error.kind(), ErrorKind::UndecodableIe);
assert_eq!(
error.to_string(),
"the DefaultPagingDRX of this NGSetupRequest does not decode: the octets end before \
the value does"
);Sourcepub fn outside_its_type(self, name: &str) -> Self
pub fn outside_its_type(self, name: &str) -> Self
A value of the type that ASN.1 names name that is written in JSON and does
not encode: it is outside a constraint of its type, and so no value of that
type. This error is what the codec said of it.
Source§impl Error
impl Error
Sourcepub fn argument(what: impl Into<String>) -> Self
pub fn argument(what: impl Into<String>) -> Self
An argument that a function does not take, and what it takes.
Sourcepub fn unknown_message(what: impl Into<String>) -> Self
pub fn unknown_message(what: impl Into<String>) -> Self
A name of a message, or a direction and a procedure code, that the protocol does not have.
Sourcepub fn unknown_ie(what: impl Into<String>) -> Self
pub fn unknown_ie(what: impl Into<String>) -> Self
A name or an identifier of an IE that the protocol does not have, or has no type for where it is.
Sourcepub fn no_such_member(what: impl Into<String>) -> Self
pub fn no_such_member(what: impl Into<String>) -> Self
A name that the type at that place cannot have.
Sourcepub fn nothing_selected(what: impl Into<String>) -> Self
pub fn nothing_selected(what: impl Into<String>) -> Self
An edit whose path selects nothing.
Sourcepub fn not_opened(what: impl Into<String>) -> Self
pub fn not_opened(what: impl Into<String>) -> Self
A path through the type that octets carry, before they are opened.
Sourcepub fn undecodable(what: impl Into<String>) -> Self
pub fn undecodable(what: impl Into<String>) -> Self
A path into an IE or a transfer that is there and did not decode.
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()