refactor(errors): adopt reportable error terminology
This commit is contained in:
1 parent
21e9497915
commit
9fec2fa095
92 files changed
+270
-269
No files matched your search
Generated
+16
-16
@@ -156,7 +156,7 @@ name = "kaptan-config"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-config-derive",
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-log",
|
||||
]
|
||||
|
||||
@@ -176,7 +176,7 @@ name = "kaptan-config-mavlink"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-config",
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-mavlink",
|
||||
]
|
||||
|
||||
@@ -198,7 +198,7 @@ dependencies = [
|
||||
name = "kaptan-control"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-math",
|
||||
]
|
||||
|
||||
@@ -207,7 +207,7 @@ name = "kaptan-data-channel"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-dma",
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-mavlink",
|
||||
"kaptan-sensor",
|
||||
"kaptan-time",
|
||||
@@ -217,7 +217,7 @@ dependencies = [
|
||||
name = "kaptan-diagnostics-mavlink"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-log",
|
||||
"kaptan-mavlink",
|
||||
"mavlink",
|
||||
@@ -231,7 +231,7 @@ version = "0.1.0"
|
||||
name = "kaptan-drivers"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-i2c",
|
||||
"kaptan-sensor",
|
||||
"kaptan-spi",
|
||||
@@ -239,14 +239,14 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kaptan-err-propagate"
|
||||
name = "kaptan-err-reportable"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-err-propagate-macros",
|
||||
"kaptan-err-reportable-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kaptan-err-propagate-macros"
|
||||
name = "kaptan-err-reportable-macros"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
@@ -260,7 +260,7 @@ name = "kaptan-flight-config"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-config",
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-log",
|
||||
"minicbor",
|
||||
]
|
||||
@@ -307,7 +307,7 @@ dependencies = [
|
||||
name = "kaptan-math"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -316,7 +316,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"kaptan-dma",
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-sensor",
|
||||
"kaptan-time",
|
||||
"kaptan-tx",
|
||||
@@ -331,7 +331,7 @@ dependencies = [
|
||||
name = "kaptan-navigation"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-math",
|
||||
"kaptan-sensor",
|
||||
"kaptan-time",
|
||||
@@ -341,7 +341,7 @@ dependencies = [
|
||||
name = "kaptan-safety"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-time",
|
||||
]
|
||||
|
||||
@@ -360,7 +360,7 @@ dependencies = [
|
||||
"kaptan-config-mavlink",
|
||||
"kaptan-control",
|
||||
"kaptan-diagnostics-mavlink",
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-flight-config",
|
||||
"kaptan-flight-runtime",
|
||||
"kaptan-log",
|
||||
@@ -509,7 +509,7 @@ dependencies = [
|
||||
"kaptan-diagnostics-mavlink",
|
||||
"kaptan-dma",
|
||||
"kaptan-drivers",
|
||||
"kaptan-err-propagate",
|
||||
"kaptan-err-reportable",
|
||||
"kaptan-i2c",
|
||||
"kaptan-log",
|
||||
"kaptan-mavlink",
|
||||
|
||||
+2
-2
@@ -10,8 +10,8 @@ members = [
|
||||
"libs/kaptan-data-channel",
|
||||
"libs/kaptan-dma",
|
||||
"libs/kaptan-drivers",
|
||||
"libs/kaptan-err-propagate",
|
||||
"libs/kaptan-err-propagate-macros",
|
||||
"libs/kaptan-err-reportable",
|
||||
"libs/kaptan-err-reportable-macros",
|
||||
"libs/kaptan-flight-config",
|
||||
"libs/kaptan-flight-runtime",
|
||||
"libs/kaptan-i2c",
|
||||
|
||||
@@ -10,5 +10,5 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-config = { path = "../kaptan-config" }
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
kaptan-mavlink = { path = "../kaptan-mavlink", default-features = false, features = ["dialect-kaptan"] }
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Stable typed outcomes for the Kaptan configuration microservice.
|
||||
|
||||
use kaptan_config::{ConfigState, ConfigViolation, FieldId};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
|
||||
/// Operation reported in an authoritative result record.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
|
||||
@@ -23,7 +23,7 @@ pub(super) struct Session {
|
||||
pub(super) revision: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, kaptan_err_propagate::KaptanError)]
|
||||
#[derive(Debug, kaptan_err_reportable::KaptanError)]
|
||||
enum CommitTransactionError<E> {
|
||||
#[kaptan_error(id = 2201)]
|
||||
Store(E),
|
||||
@@ -337,9 +337,9 @@ impl ConfigProtocol {
|
||||
|
||||
/// Classifies expected configuration rejection separately from a terminal
|
||||
/// persistence failure. Only the latter leaves this boundary and becomes
|
||||
/// a typed firmware error; the configuration result remains authoritative
|
||||
/// a reportable firmware error; the configuration result remains authoritative
|
||||
/// for the requesting user.
|
||||
#[kaptan_err_propagate::propagate]
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn commit_transaction<C, S>(
|
||||
&mut self,
|
||||
manager: &mut ConfigManager<C, S>,
|
||||
@@ -1235,7 +1235,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn failed_commit_reports_the_returned_error_only_once() {
|
||||
while kaptan_err_propagate::take().is_some() {}
|
||||
while kaptan_err_reportable::take().is_some() {}
|
||||
let persists = Rc::new(Cell::new(0));
|
||||
let store = FailingStore(Rc::clone(&persists));
|
||||
let mut manager = ConfigManager::new(Candidate(2), (), store).unwrap();
|
||||
@@ -1277,9 +1277,9 @@ mod tests {
|
||||
Some(ProtocolError::StorageFailure)
|
||||
);
|
||||
let error =
|
||||
kaptan_err_propagate::take().expect("failed commit must report its returned error");
|
||||
kaptan_err_reportable::take().expect("failed commit must report its returned error");
|
||||
assert_eq!(error.id(), 2201);
|
||||
while kaptan_err_propagate::take().is_some() {}
|
||||
while kaptan_err_reportable::take().is_some() {}
|
||||
|
||||
protocol
|
||||
.dispatch(&mut manager, Authorized::host(7, commit), |_| {
|
||||
@@ -1288,7 +1288,7 @@ mod tests {
|
||||
.unwrap();
|
||||
assert_eq!(persists.get(), 1);
|
||||
assert!(
|
||||
kaptan_err_propagate::take().is_none(),
|
||||
kaptan_err_reportable::take().is_none(),
|
||||
"a cached command replay must not report the error again"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use kaptan_config::{
|
||||
ConfigState, ConfigValue, FieldDescriptor, FieldId, ValidationRule, ValueKind,
|
||||
};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_mavlink::message::Message;
|
||||
use kaptan_mavlink::message::kaptan::{
|
||||
KAPTAN_CONFIG_DESCRIPTOR_DATA, KAPTAN_CONFIG_ENUM_OPTION_DATA, KAPTAN_CONFIG_INFO_DATA,
|
||||
|
||||
@@ -10,5 +10,5 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-config-derive = { path = "../kaptan-config-derive" }
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
kaptan-log = { path = "../kaptan-log" }
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Transport-neutral typed configuration fields and descriptors.
|
||||
|
||||
use crate::{ConfigViolation, ValidationRule};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
|
||||
/// Maximum choices representable by one enum-backed field.
|
||||
///
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::{
|
||||
ConfigModel, ConfigStore, ConfigValue, ConfigViolation, FieldDescriptor, FieldId,
|
||||
FieldWriteError,
|
||||
};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
|
||||
/// Observable state of the bounded configuration transaction slot.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
//! field IDs and therefore also accepts a complete, uniquely identified set in
|
||||
//! another order.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
|
||||
use crate::{ConfigModel, ConfigValue, FieldId, FieldWriteError, ValueKind};
|
||||
|
||||
|
||||
@@ -9,5 +9,5 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
kaptan-math = { path = "../kaptan-math" }
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#![no_std]
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_math::{Frd, Ned, UnitQuaternion, Vector3, sqrt};
|
||||
|
||||
/// Body-frame angular rate in radians per second.
|
||||
|
||||
@@ -9,7 +9,7 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
kaptan-dma = { path = "../kaptan-dma" }
|
||||
kaptan-mavlink = { path = "../kaptan-mavlink" }
|
||||
kaptan-sensor = { path = "../kaptan-sensor" }
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#![no_std]
|
||||
|
||||
use kaptan_dma::TxCompletion;
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_mavlink::message::MessageData;
|
||||
use kaptan_mavlink::{
|
||||
MavlinkFrame,
|
||||
|
||||
@@ -9,7 +9,7 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
kaptan-log = { path = "../kaptan-log" }
|
||||
kaptan-mavlink = { path = "../kaptan-mavlink", default-features = false, features = ["dialect-kaptan"] }
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! MAVLink projection for Kaptan logs and typed firmware errors.
|
||||
//! MAVLink projection for Kaptan logs and reportable firmware errors.
|
||||
//!
|
||||
//! This adapter creates generated payload data only. A platform-owned link is
|
||||
//! solely responsible for MAVLink framing, bounded admission, DMA, and retry
|
||||
@@ -9,7 +9,7 @@
|
||||
#[cfg(test)]
|
||||
extern crate std;
|
||||
|
||||
use kaptan_err_propagate::ErrorRecord;
|
||||
use kaptan_err_reportable::ErrorRecord;
|
||||
use kaptan_log::{Level, LogRecord, MAXIMUM_LOG_TEXT_BYTES};
|
||||
use kaptan_mavlink::message::kaptan::{KAPTAN_ERROR_DATA, KAPTAN_LOG_DATA, KaptanLogFlags};
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn encode_log(record: &LogRecord) -> KAPTAN_LOG_DATA {
|
||||
}
|
||||
}
|
||||
|
||||
/// Encodes one typed firmware error as its sole wire message.
|
||||
/// Encodes one reportable firmware error as its sole wire message.
|
||||
pub fn encode_error(record: &ErrorRecord) -> KAPTAN_ERROR_DATA {
|
||||
let source = record.raised_at().as_bytes();
|
||||
let mut length = source.len().min(ERROR_RAISED_AT_BYTES);
|
||||
@@ -63,7 +63,7 @@ const fn mavlink_severity(level: Level) -> u8 {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{LOG_MESSAGE_BYTES, encode_error, encode_log};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_log::{Level, LogFlags, LogRecord, LogText};
|
||||
use kaptan_mavlink::{
|
||||
MavlinkVersion,
|
||||
@@ -80,8 +80,8 @@ mod tests {
|
||||
Transfer,
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
fn report_typed_error() -> Result<(), TestError> {
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn report_reportable_error() -> Result<(), TestError> {
|
||||
Err(TestError::Transfer)
|
||||
}
|
||||
|
||||
@@ -148,9 +148,9 @@ mod tests {
|
||||
Ok(MavMessage::KAPTAN_LOG(decoded)) if decoded == data
|
||||
));
|
||||
|
||||
while kaptan_err_propagate::take().is_some() {}
|
||||
assert_eq!(report_typed_error(), Err(TestError::Transfer));
|
||||
let error = kaptan_err_propagate::take().expect("typed error retained");
|
||||
while kaptan_err_reportable::take().is_some() {}
|
||||
assert_eq!(report_reportable_error(), Err(TestError::Transfer));
|
||||
let error = kaptan_err_reportable::take().expect("reportable error retained");
|
||||
let error_data = encode_error(&error);
|
||||
assert_eq!(error_data.error_id, error.id());
|
||||
assert_eq!(KAPTAN_ERROR_DATA::ENCODED_LEN, 98);
|
||||
|
||||
@@ -9,7 +9,7 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
kaptan-sensor = { path = "../kaptan-sensor" }
|
||||
kaptan-i2c = { path = "../kaptan-i2c" }
|
||||
kaptan-spi = { path = "../kaptan-spi" }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! ICM-42688-P operation errors.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
|
||||
/// ICM-42688-P operation failure.
|
||||
#[derive(Debug, Eq, PartialEq, KaptanError)]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! LIDAR-Lite v3 operation errors.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
|
||||
/// LIDAR-Lite v3 operation failure.
|
||||
#[derive(Debug, Eq, PartialEq, KaptanError)]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! MPU6000 operation errors.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
|
||||
/// MPU6000 operation failure.
|
||||
#[derive(Debug, Eq, PartialEq, KaptanError)]
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
extern crate self as kaptan_err_propagate;
|
||||
|
||||
use kaptan_err_propagate_macros::KaptanError;
|
||||
|
||||
#[derive(Debug, KaptanError)]
|
||||
enum MissingId {
|
||||
Variant,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -1,6 +0,0 @@
|
||||
use kaptan_err_propagate_macros::propagate;
|
||||
|
||||
#[propagate]
|
||||
fn invalid() {}
|
||||
|
||||
fn main() {}
|
||||
@@ -1,18 +0,0 @@
|
||||
use kaptan_err_propagate_macros::propagate;
|
||||
|
||||
extern crate self as kaptan_err_propagate;
|
||||
|
||||
pub trait ErrorReport {}
|
||||
|
||||
pub mod __private {
|
||||
pub fn report_result<T, E: crate::ErrorReport>(_: &Result<T, E>, _: &'static str) {}
|
||||
}
|
||||
|
||||
struct PlainError;
|
||||
|
||||
#[propagate]
|
||||
fn invalid() -> Result<(), PlainError> {
|
||||
Err(PlainError)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -1,17 +0,0 @@
|
||||
error[E0277]: the trait bound `PlainError: ErrorReport` is not satisfied
|
||||
--> tests/ui/no_error_report.rs:13:1
|
||||
|
|
||||
13 | #[propagate]
|
||||
| ^^^^^^^^^^^^ the trait `ErrorReport` is not implemented for `PlainError`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> tests/ui/no_error_report.rs:5:1
|
||||
|
|
||||
5 | pub trait ErrorReport {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `report_result`
|
||||
--> tests/ui/no_error_report.rs:8:32
|
||||
|
|
||||
8 | pub fn report_result<T, E: crate::ErrorReport>(_: &Result<T, E>, _: &'static str) {}
|
||||
| ^^^^^^^^^^^^^^^^^^ required by this bound in `report_result`
|
||||
= note: this error originates in the attribute macro `propagate` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "kaptan-err-propagate-macros"
|
||||
name = "kaptan-err-reportable-macros"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
rust-version.workspace = true
|
||||
+20
-20
@@ -1,4 +1,4 @@
|
||||
//! Attribute expansion for `kaptan-err-propagate`.
|
||||
//! Attribute expansion for `kaptan-err-reportable`.
|
||||
|
||||
use proc_macro::TokenStream;
|
||||
use quote::{format_ident, quote};
|
||||
@@ -8,7 +8,7 @@ use syn::{
|
||||
parse_quote, spanned::Spanned,
|
||||
};
|
||||
|
||||
/// Implements `kaptan_err_propagate::ErrorReport`, [`core::fmt::Display`], and
|
||||
/// Implements `kaptan_err_reportable::ReportableError`, [`core::fmt::Display`], and
|
||||
/// [`core::error::Error`] for an explicitly numbered error enum.
|
||||
///
|
||||
/// Every variant must declare a stable nonzero
|
||||
@@ -34,7 +34,7 @@ pub fn propagate(arguments: TokenStream, input: TokenStream) -> TokenStream {
|
||||
if !arguments.is_empty() {
|
||||
return Error::new(
|
||||
proc_macro2::Span::call_site(),
|
||||
"kaptan_err_propagate::propagate does not accept arguments",
|
||||
"kaptan_err_reportable::propagate does not accept arguments",
|
||||
)
|
||||
.into_compile_error()
|
||||
.into();
|
||||
@@ -53,22 +53,22 @@ fn expand(mut function: ItemFn) -> syn::Result<proc_macro2::TokenStream> {
|
||||
function.block = if function.sig.asyncness.is_some() {
|
||||
Box::new(syn::parse_quote!({
|
||||
const __KAPTAN_RAISED_AT: &str = concat!(file!(), ":", line!());
|
||||
let __kaptan_err_propagate_result = (async #body).await;
|
||||
::kaptan_err_propagate::__private::report_result(
|
||||
&__kaptan_err_propagate_result,
|
||||
let __kaptan_err_reportable_result = (async #body).await;
|
||||
::kaptan_err_reportable::__private::report_result(
|
||||
&__kaptan_err_reportable_result,
|
||||
__KAPTAN_RAISED_AT,
|
||||
);
|
||||
__kaptan_err_propagate_result
|
||||
__kaptan_err_reportable_result
|
||||
}))
|
||||
} else {
|
||||
Box::new(syn::parse_quote!({
|
||||
const __KAPTAN_RAISED_AT: &str = concat!(file!(), ":", line!());
|
||||
let __kaptan_err_propagate_result = (|| #body)();
|
||||
::kaptan_err_propagate::__private::report_result(
|
||||
&__kaptan_err_propagate_result,
|
||||
let __kaptan_err_reportable_result = (|| #body)();
|
||||
::kaptan_err_reportable::__private::report_result(
|
||||
&__kaptan_err_reportable_result,
|
||||
__KAPTAN_RAISED_AT,
|
||||
);
|
||||
__kaptan_err_propagate_result
|
||||
__kaptan_err_reportable_result
|
||||
}))
|
||||
};
|
||||
|
||||
@@ -80,32 +80,32 @@ fn validate_signature(function: &ItemFn) -> syn::Result<()> {
|
||||
if let Some(token) = signature.constness {
|
||||
return Err(Error::new(
|
||||
token.span(),
|
||||
"kaptan_err_propagate::propagate does not support const functions",
|
||||
"kaptan_err_reportable::propagate does not support const functions",
|
||||
));
|
||||
}
|
||||
if let Some(token) = signature.unsafety {
|
||||
return Err(Error::new(
|
||||
token.span(),
|
||||
"kaptan_err_propagate::propagate does not support unsafe functions",
|
||||
"kaptan_err_reportable::propagate does not support unsafe functions",
|
||||
));
|
||||
}
|
||||
if let Some(abi) = &signature.abi {
|
||||
return Err(Error::new(
|
||||
abi.span(),
|
||||
"kaptan_err_propagate::propagate does not support foreign-ABI functions",
|
||||
"kaptan_err_reportable::propagate does not support foreign-ABI functions",
|
||||
));
|
||||
}
|
||||
if let Some(variadic) = &signature.variadic {
|
||||
return Err(Error::new(
|
||||
variadic.span(),
|
||||
"kaptan_err_propagate::propagate does not support variadic functions",
|
||||
"kaptan_err_reportable::propagate does not support variadic functions",
|
||||
));
|
||||
}
|
||||
|
||||
if matches!(signature.output, ReturnType::Default) {
|
||||
return Err(Error::new(
|
||||
signature.output.span(),
|
||||
"kaptan_err_propagate::propagate requires an explicit Result<T, E> return type",
|
||||
"kaptan_err_reportable::propagate requires an explicit Result<T, E> return type",
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
@@ -168,7 +168,7 @@ fn expand_error(input: DeriveInput) -> syn::Result<proc_macro2::TokenStream> {
|
||||
Fields::Named(_) => quote!(Self::#variant_ident { .. }),
|
||||
};
|
||||
quote! {
|
||||
#pattern => ::kaptan_err_propagate::ErrorId::new(#id)
|
||||
#pattern => ::kaptan_err_reportable::ErrorId::new(#id)
|
||||
}
|
||||
});
|
||||
let (impl_generics, type_generics, where_clause) = generics.split_for_impl();
|
||||
@@ -183,8 +183,8 @@ fn expand_error(input: DeriveInput) -> syn::Result<proc_macro2::TokenStream> {
|
||||
Ok(quote! {
|
||||
#(#identities)*
|
||||
|
||||
impl #impl_generics ::kaptan_err_propagate::ErrorReport for #ident #type_generics #where_clause {
|
||||
fn error_id(&self) -> ::kaptan_err_propagate::ErrorId {
|
||||
impl #impl_generics ::kaptan_err_reportable::ReportableError for #ident #type_generics #where_clause {
|
||||
fn error_id(&self) -> ::kaptan_err_reportable::ErrorId {
|
||||
match self {
|
||||
#(#arms),*
|
||||
}
|
||||
@@ -197,7 +197,7 @@ fn expand_error(input: DeriveInput) -> syn::Result<proc_macro2::TokenStream> {
|
||||
formatter: &mut ::core::fmt::Formatter<'_>,
|
||||
) -> ::core::fmt::Result {
|
||||
::core::fmt::Display::fmt(
|
||||
&<Self as ::kaptan_err_propagate::ErrorReport>::error_id(self).get(),
|
||||
&<Self as ::kaptan_err_reportable::ReportableError>::error_id(self).get(),
|
||||
formatter,
|
||||
)
|
||||
}
|
||||
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
||||
use kaptan_err_propagate_macros::propagate;
|
||||
use kaptan_err_reportable_macros::propagate;
|
||||
|
||||
#[propagate(report)]
|
||||
fn invalid() -> Result<(), ()> {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
error: kaptan_err_propagate::propagate does not accept arguments
|
||||
error: kaptan_err_reportable::propagate does not accept arguments
|
||||
--> tests/ui/arguments.rs:3:1
|
||||
|
|
||||
3 | #[propagate(report)]
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
use kaptan_err_propagate_macros::propagate;
|
||||
use kaptan_err_reportable_macros::propagate;
|
||||
|
||||
#[propagate]
|
||||
const fn invalid() -> Result<(), ()> {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
error: kaptan_err_propagate::propagate does not support const functions
|
||||
error: kaptan_err_reportable::propagate does not support const functions
|
||||
--> tests/ui/const_fn.rs:4:1
|
||||
|
|
||||
4 | const fn invalid() -> Result<(), ()> {
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
extern crate self as kaptan_err_propagate;
|
||||
extern crate self as kaptan_err_reportable;
|
||||
|
||||
use kaptan_err_propagate_macros::KaptanError;
|
||||
use kaptan_err_reportable_macros::KaptanError;
|
||||
|
||||
#[derive(Debug, KaptanError)]
|
||||
enum DuplicateId {
|
||||
File renamed without changes.
+3
-3
@@ -1,6 +1,6 @@
|
||||
extern crate self as kaptan_err_propagate;
|
||||
extern crate self as kaptan_err_reportable;
|
||||
|
||||
use kaptan_err_propagate_macros::KaptanError;
|
||||
use kaptan_err_reportable_macros::KaptanError;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ErrorId(u16);
|
||||
@@ -15,7 +15,7 @@ impl ErrorId {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ErrorReport {
|
||||
pub trait ReportableError {
|
||||
fn error_id(&self) -> ErrorId;
|
||||
}
|
||||
|
||||
File renamed without changes.
+3
-3
@@ -1,6 +1,6 @@
|
||||
extern crate self as kaptan_err_propagate;
|
||||
extern crate self as kaptan_err_reportable;
|
||||
|
||||
use kaptan_err_propagate_macros::KaptanError;
|
||||
use kaptan_err_reportable_macros::KaptanError;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct ErrorId(u16);
|
||||
@@ -15,7 +15,7 @@ impl ErrorId {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ErrorReport {
|
||||
pub trait ReportableError {
|
||||
fn error_id(&self) -> ErrorId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
extern crate self as kaptan_err_reportable;
|
||||
|
||||
use kaptan_err_reportable_macros::KaptanError;
|
||||
|
||||
#[derive(Debug, KaptanError)]
|
||||
enum MissingId {
|
||||
Variant,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
File renamed without changes.
@@ -0,0 +1,6 @@
|
||||
use kaptan_err_reportable_macros::propagate;
|
||||
|
||||
#[propagate]
|
||||
fn invalid() {}
|
||||
|
||||
fn main() {}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
error: kaptan_err_propagate::propagate requires an explicit Result<T, E> return type
|
||||
error: kaptan_err_reportable::propagate requires an explicit Result<T, E> return type
|
||||
--> tests/ui/missing_return.rs:3:1
|
||||
|
|
||||
3 | #[propagate]
|
||||
@@ -0,0 +1,18 @@
|
||||
use kaptan_err_reportable_macros::propagate;
|
||||
|
||||
extern crate self as kaptan_err_reportable;
|
||||
|
||||
pub trait ReportableError {}
|
||||
|
||||
pub mod __private {
|
||||
pub fn report_result<T, E: crate::ReportableError>(_: &Result<T, E>, _: &'static str) {}
|
||||
}
|
||||
|
||||
struct PlainError;
|
||||
|
||||
#[propagate]
|
||||
fn invalid() -> Result<(), PlainError> {
|
||||
Err(PlainError)
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,17 @@
|
||||
error[E0277]: the trait bound `PlainError: ReportableError` is not satisfied
|
||||
--> tests/ui/no_error_report.rs:13:1
|
||||
|
|
||||
13 | #[propagate]
|
||||
| ^^^^^^^^^^^^ the trait `ReportableError` is not implemented for `PlainError`
|
||||
|
|
||||
help: this trait has no implementations, consider adding one
|
||||
--> tests/ui/no_error_report.rs:5:1
|
||||
|
|
||||
5 | pub trait ReportableError {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: required by a bound in `report_result`
|
||||
--> tests/ui/no_error_report.rs:8:32
|
||||
|
|
||||
8 | pub fn report_result<T, E: crate::ReportableError>(_: &Result<T, E>, _: &'static str) {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `report_result`
|
||||
= note: this error originates in the attribute macro `propagate` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
use kaptan_err_propagate_macros::propagate;
|
||||
use kaptan_err_reportable_macros::propagate;
|
||||
|
||||
extern crate self as kaptan_err_propagate;
|
||||
extern crate self as kaptan_err_reportable;
|
||||
|
||||
pub mod __private {
|
||||
pub fn report_result<T, E>(_: &Result<T, E>, _: &'static str) {}
|
||||
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
||||
use kaptan_err_propagate_macros::KaptanError;
|
||||
use kaptan_err_reportable_macros::KaptanError;
|
||||
|
||||
#[derive(KaptanError)]
|
||||
struct NotAnError {
|
||||
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
||||
use kaptan_err_propagate_macros::KaptanError;
|
||||
use kaptan_err_reportable_macros::KaptanError;
|
||||
|
||||
#[derive(KaptanError)]
|
||||
union NotAnError {
|
||||
File renamed without changes.
+1
-1
@@ -1,4 +1,4 @@
|
||||
use kaptan_err_propagate_macros::propagate;
|
||||
use kaptan_err_reportable_macros::propagate;
|
||||
|
||||
#[propagate]
|
||||
unsafe fn invalid() -> Result<(), ()> {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
error: kaptan_err_propagate::propagate does not support unsafe functions
|
||||
error: kaptan_err_reportable::propagate does not support unsafe functions
|
||||
--> tests/ui/unsafe_fn.rs:4:1
|
||||
|
|
||||
4 | unsafe fn invalid() -> Result<(), ()> {
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
extern crate self as kaptan_err_propagate;
|
||||
extern crate self as kaptan_err_reportable;
|
||||
|
||||
use kaptan_err_propagate_macros::KaptanError;
|
||||
use kaptan_err_reportable_macros::KaptanError;
|
||||
|
||||
#[derive(Debug, KaptanError)]
|
||||
enum ZeroId {
|
||||
File renamed without changes.
+2
-2
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "kaptan-err-propagate"
|
||||
name = "kaptan-err-reportable"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
rust-version.workspace = true
|
||||
@@ -9,4 +9,4 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-err-propagate-macros = { path = "../kaptan-err-propagate-macros" }
|
||||
kaptan-err-reportable-macros = { path = "../kaptan-err-reportable-macros" }
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
//! Fixed, allocation-free typed-error ingress.
|
||||
//! Fixed, allocation-free reportable-error ingress.
|
||||
|
||||
use core::{
|
||||
cell::UnsafeCell,
|
||||
@@ -68,7 +68,7 @@ pub(crate) fn publish(id: ErrorId, raised_at: &'static str) {
|
||||
GLOBAL_INGRESS.publish(id, raised_at);
|
||||
}
|
||||
|
||||
/// Takes the pending typed firmware error, if one exists.
|
||||
/// Takes the pending reportable firmware error, if one exists.
|
||||
pub fn take() -> Option<ErrorRecord> {
|
||||
GLOBAL_INGRESS.take()
|
||||
}
|
||||
+10
-9
@@ -1,12 +1,13 @@
|
||||
//! Bounded typed firmware errors and function-boundary propagation.
|
||||
//! Stable reportable firmware errors with bounded diagnostic ingress.
|
||||
//!
|
||||
//! This crate owns error identity and ingress. It contains no logging levels,
|
||||
//! filtering, MAVLink, board, filesystem, or clock dependency.
|
||||
//!
|
||||
//! `#[propagate]` reports at each annotated boundary. Annotate the terminal
|
||||
//! boundary where an error enters diagnostics; nested annotated callers would
|
||||
//! attempt to report the same propagation again. The bounded ingress retaining
|
||||
//! only one pending error is backpressure, not semantic duplicate suppression.
|
||||
//! `#[propagate]` turns an annotated function into a reporting point. When a
|
||||
//! reportable error leaves that function, the macro makes one reporting
|
||||
//! attempt. Nested annotated callers would therefore attempt to report the
|
||||
//! same error again. The bounded ingress retaining only one pending error is
|
||||
//! backpressure, not semantic duplicate suppression.
|
||||
|
||||
#![no_std]
|
||||
|
||||
@@ -18,19 +19,19 @@ mod record;
|
||||
mod sink;
|
||||
|
||||
pub use ingress::take;
|
||||
pub use kaptan_err_propagate_macros::{KaptanError, propagate};
|
||||
pub use record::{ErrorId, ErrorRecord, ErrorReport};
|
||||
pub use kaptan_err_reportable_macros::{KaptanError, propagate};
|
||||
pub use record::{ErrorId, ErrorRecord, ReportableError};
|
||||
pub use sink::ErrorSink;
|
||||
|
||||
/// Implementation details used only by macro expansions.
|
||||
#[doc(hidden)]
|
||||
pub mod __private {
|
||||
use crate::ErrorReport;
|
||||
use crate::ReportableError;
|
||||
|
||||
/// Reports an error only when it is the final result leaving an annotated
|
||||
/// function. Borrowing preserves the exact result returned to the caller.
|
||||
#[inline]
|
||||
pub fn report_result<T, E: ErrorReport>(
|
||||
pub fn report_result<T, E: ReportableError>(
|
||||
result: &core::result::Result<T, E>,
|
||||
raised_at: &'static str,
|
||||
) {
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
//! Stable error IDs and bounded pending records.
|
||||
|
||||
/// Stable nonzero identity for one typed firmware error variant.
|
||||
/// Stable nonzero identity for one reportable firmware error variant.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[repr(transparent)]
|
||||
pub struct ErrorId(u16);
|
||||
@@ -21,18 +21,18 @@ impl ErrorId {
|
||||
/// Implemented by [`crate::KaptanError`] derives.
|
||||
///
|
||||
/// Obtaining an ID never publishes, allocates, or changes safety state.
|
||||
pub trait ErrorReport {
|
||||
pub trait ReportableError {
|
||||
/// Returns the stable ID assigned to this error variant.
|
||||
fn error_id(&self) -> ErrorId;
|
||||
}
|
||||
|
||||
impl ErrorReport for ErrorId {
|
||||
impl ReportableError for ErrorId {
|
||||
fn error_id(&self) -> ErrorId {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
/// One reported typed firmware error and its reporting boundary.
|
||||
/// One reported firmware error and its reporting point.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub struct ErrorRecord {
|
||||
id: ErrorId,
|
||||
@@ -49,7 +49,7 @@ impl ErrorRecord {
|
||||
self.id.get()
|
||||
}
|
||||
|
||||
/// Compile-time `file:line` of the propagation boundary that reported it.
|
||||
/// Compile-time `file:line` of the reporting point.
|
||||
pub const fn raised_at(self) -> &'static str {
|
||||
self.raised_at
|
||||
}
|
||||
@@ -60,7 +60,7 @@ mod tests {
|
||||
use super::{ErrorId, ErrorRecord};
|
||||
|
||||
#[test]
|
||||
fn record_keeps_only_the_explicit_id_and_reporting_boundary() {
|
||||
fn record_keeps_only_the_explicit_id_and_reporting_point() {
|
||||
let record = ErrorRecord::new(ErrorId::new(65004), "module.rs:42");
|
||||
assert_eq!(record.id(), 65004);
|
||||
assert_eq!(record.raised_at(), "module.rs:42");
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
//! One-slot retry ownership for a typed-error sink.
|
||||
//! One-slot retry ownership for a reportable-error sink.
|
||||
|
||||
use crate::ErrorRecord;
|
||||
|
||||
/// Retains one typed error until a lower sink accepts it.
|
||||
/// Retains one reportable error until a lower sink accepts it.
|
||||
///
|
||||
/// Typed errors are never filtered. A composition may give them priority over
|
||||
/// Reportable errors are never filtered. A composition may give them priority over
|
||||
/// best-effort logs without coupling the producer to its transport.
|
||||
pub struct ErrorSink {
|
||||
pending: Option<ErrorRecord>,
|
||||
+26
-26
@@ -1,4 +1,4 @@
|
||||
use kaptan_err_propagate::{ErrorId, ErrorReport, KaptanError};
|
||||
use kaptan_err_reportable::{ErrorId, KaptanError, ReportableError};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, KaptanError)]
|
||||
enum TestError {
|
||||
@@ -26,18 +26,18 @@ fn middle() -> Result<(), TestError> {
|
||||
fail()
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn succeeds() -> Result<u8, TestError> {
|
||||
Ok(7)
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn annotated_outer() -> Result<(), TestError> {
|
||||
middle()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn annotated_inner() -> Result<(), TestError> {
|
||||
fail()
|
||||
}
|
||||
@@ -46,15 +46,15 @@ fn unannotated_outer() -> Result<(), TestError> {
|
||||
annotated_inner()
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn handles_inner_error() -> Result<(), TestError> {
|
||||
let _handled = fail().is_err();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
fn returns_explicit_error(fail_at_boundary: bool) -> Result<(), TestError> {
|
||||
if fail_at_boundary {
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn returns_explicit_error(report_error: bool) -> Result<(), TestError> {
|
||||
if report_error {
|
||||
return Err(TestError::Failed);
|
||||
}
|
||||
Ok(())
|
||||
@@ -62,24 +62,24 @@ fn returns_explicit_error(fail_at_boundary: bool) -> Result<(), TestError> {
|
||||
|
||||
type AliasedResult<T> = core::result::Result<T, TestError>;
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn returns_alias() -> AliasedResult<()> {
|
||||
fail()
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
fn reports_final_converted_error() -> Result<(), OuterError> {
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn reports_converted_error() -> Result<(), OuterError> {
|
||||
fail()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn reports_error_id() -> Result<(), ErrorId> {
|
||||
Err(ErrorId::new(65003))
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
async fn async_boundary() -> Result<(), TestError> {
|
||||
#[kaptan_err_reportable::propagate]
|
||||
async fn async_reporting_point() -> Result<(), TestError> {
|
||||
fail()?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -87,28 +87,28 @@ async fn async_boundary() -> Result<(), TestError> {
|
||||
struct Service;
|
||||
|
||||
impl Service {
|
||||
#[kaptan_err_propagate::propagate]
|
||||
fn method(&self, fail_at_boundary: bool) -> Result<(), TestError> {
|
||||
if fail_at_boundary {
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn method(&self, report_error: bool) -> Result<(), TestError> {
|
||||
if report_error {
|
||||
fail()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn take_record() -> kaptan_err_propagate::ErrorRecord {
|
||||
kaptan_err_propagate::take().expect("escaping error must be reported")
|
||||
fn take_record() -> kaptan_err_reportable::ErrorRecord {
|
||||
kaptan_err_reportable::take().expect("escaping error must be reported")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reports_only_final_errors_leaving_annotated_boundaries() {
|
||||
while kaptan_err_propagate::take().is_some() {}
|
||||
fn reports_only_errors_leaving_annotated_reporting_points() {
|
||||
while kaptan_err_reportable::take().is_some() {}
|
||||
|
||||
assert_eq!(succeeds(), Ok(7));
|
||||
assert!(kaptan_err_propagate::take().is_none());
|
||||
assert!(kaptan_err_reportable::take().is_none());
|
||||
|
||||
assert_eq!(handles_inner_error(), Ok(()));
|
||||
assert!(kaptan_err_propagate::take().is_none());
|
||||
assert!(kaptan_err_reportable::take().is_none());
|
||||
|
||||
assert_eq!(annotated_outer(), Err(TestError::Failed));
|
||||
assert_eq!(take_record().id(), TestError::Failed.error_id().get());
|
||||
@@ -123,7 +123,7 @@ fn reports_only_final_errors_leaving_annotated_boundaries() {
|
||||
assert_eq!(take_record().id(), TestError::Failed.error_id().get());
|
||||
|
||||
assert_eq!(
|
||||
reports_final_converted_error(),
|
||||
reports_converted_error(),
|
||||
Err(OuterError::Converted(TestError::Failed))
|
||||
);
|
||||
assert_eq!(
|
||||
@@ -135,9 +135,9 @@ fn reports_only_final_errors_leaving_annotated_boundaries() {
|
||||
assert_eq!(take_record().id(), 65003);
|
||||
|
||||
assert_eq!(Service.method(false), Ok(()));
|
||||
assert!(kaptan_err_propagate::take().is_none());
|
||||
assert!(kaptan_err_reportable::take().is_none());
|
||||
|
||||
let mut future = core::pin::pin!(async_boundary());
|
||||
let mut future = core::pin::pin!(async_reporting_point());
|
||||
let mut context = core::task::Context::from_waker(core::task::Waker::noop());
|
||||
assert_eq!(
|
||||
core::future::Future::poll(future.as_mut(), &mut context),
|
||||
@@ -10,6 +10,6 @@ workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-config = { path = "../kaptan-config" }
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
kaptan-log = { path = "../kaptan-log" }
|
||||
minicbor = { version = "0.25", features = ["derive"] }
|
||||
@@ -3,7 +3,7 @@
|
||||
use kaptan_config::{
|
||||
ConfigModel, ConfigValue, ConfigViolation, FieldWriteError, ValidationRule, ValueKind,
|
||||
};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use minicbor::{Decoder, Encoder, encode::Write};
|
||||
|
||||
use crate::{CandidateProfile, FORMAT_VERSION, SCHEMA_ID, VehicleCapabilities};
|
||||
|
||||
@@ -9,4 +9,4 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
@@ -7,7 +7,7 @@
|
||||
#![no_std]
|
||||
|
||||
use core::marker::PhantomData;
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
|
||||
/// Failure reported by a checked mathematical operation.
|
||||
///
|
||||
|
||||
@@ -16,7 +16,7 @@ sensor-telemetry = ["dep:kaptan-sensor"]
|
||||
dialect-kaptan = []
|
||||
|
||||
[dependencies]
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
kaptan-dma = { path = "../kaptan-dma" }
|
||||
kaptan-sensor = { path = "../kaptan-sensor", optional = true }
|
||||
kaptan-tx = { path = "../kaptan-tx" }
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
<!-- Kaptan-reserved development block. Register these IDs before release. -->
|
||||
<messages>
|
||||
<message id="51021" name="KAPTAN_ERROR">
|
||||
<description>Typed firmware error reported when an Err leaves an annotated propagation boundary. This is distinct from every logging macro, which emits KAPTAN_LOG. The stable ID is explicitly assigned to the Rust error variant. Structured configuration failures remain authoritative in KAPTAN_CONFIG_RESULT.</description>
|
||||
<description>Reportable firmware error emitted when an Err leaves an annotated reporting point. This is distinct from every logging macro, which emits KAPTAN_LOG. The stable ID is explicitly assigned to the Rust error variant. Structured configuration failures remain authoritative in KAPTAN_CONFIG_RESULT.</description>
|
||||
<field type="uint16_t" name="error_id">Stable explicitly assigned error catalog ID. Zero is reserved.</field>
|
||||
<field type="uint8_t[96]" name="raised_at">Zero-padded compile-time file:line of the propagation boundary that reported the error.</field>
|
||||
<field type="uint8_t[96]" name="raised_at">Zero-padded compile-time file:line of the reporting point.</field>
|
||||
</message>
|
||||
</messages>
|
||||
</mavlink>
|
||||
@@ -1,7 +1,7 @@
|
||||
//! MAVLink frame encoding and UART transmission API.
|
||||
|
||||
use kaptan_dma::{DmaTxBufferFactory, DmaTxEngine, TxCompletion};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_tx::{PendingFrame, TransmitQueue};
|
||||
|
||||
use crate::MavlinkFrame;
|
||||
|
||||
@@ -14,7 +14,7 @@ default = []
|
||||
# executable. It is not part of a board build.
|
||||
sitl = ["dep:kaptan-sensor"]
|
||||
[dependencies]
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
kaptan-math = { path = "../kaptan-math" }
|
||||
kaptan-sensor = { path = "../kaptan-sensor", optional = true }
|
||||
kaptan-time = { path = "../kaptan-time" }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Fixed-size multiplicative error-state Kalman filter.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_math::{Frd, MathError, Ned, Sensor, UnitQuaternion, Vector3, sqrt};
|
||||
use kaptan_time::Timestamp;
|
||||
|
||||
|
||||
@@ -9,5 +9,5 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-err-propagate = { path = "../kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../kaptan-err-reportable" }
|
||||
kaptan-time = { path = "../kaptan-time" }
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#![no_std]
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_time::Timestamp;
|
||||
|
||||
/// Supervisor arming state.
|
||||
|
||||
@@ -15,7 +15,7 @@ workspace = true
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
kaptan-err-propagate = { path = "../../libs/kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../../libs/kaptan-err-reportable" }
|
||||
kaptan-config = { path = "../../libs/kaptan-config" }
|
||||
kaptan-config-mavlink = { path = "../../libs/kaptan-config-mavlink" }
|
||||
kaptan-data-channel = { path = "../../libs/kaptan-data-channel" }
|
||||
|
||||
@@ -22,7 +22,7 @@ use kaptan_drivers::{
|
||||
},
|
||||
mtf01::Mtf01Service,
|
||||
};
|
||||
use kaptan_err_propagate::{ErrorId, ErrorSink};
|
||||
use kaptan_err_reportable::{ErrorId, ErrorSink};
|
||||
use kaptan_log::{DeliveryClass, LogSinkQueue, TransportAdmission};
|
||||
use kaptan_spi::SpiCompletion;
|
||||
use stm32f7::stm32f722;
|
||||
@@ -525,7 +525,7 @@ impl F722LidarState {
|
||||
let _ = publish_lidar_event(event);
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
#[kaptan_err_reportable::propagate]
|
||||
pub fn on_timer(&mut self) -> Result<(), StartupError> {
|
||||
if let Some(range) = self.range.as_mut() {
|
||||
if self.startup_ticks < LIDAR_STARTUP_TICKS {
|
||||
@@ -568,7 +568,7 @@ pub fn process_imu(imu: &mut F722Imu, events: u8) {
|
||||
}
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn accept_imu_event(event: ImuEvent) -> Result<(), ErrorId> {
|
||||
match event {
|
||||
ImuEvent::Sample(sample) => {
|
||||
@@ -683,7 +683,7 @@ where
|
||||
|
||||
fn drain_one_mavlink_diagnostic(&mut self) {
|
||||
if self.mavlink_errors.is_empty()
|
||||
&& let Some(record) = kaptan_err_propagate::take()
|
||||
&& let Some(record) = kaptan_err_reportable::take()
|
||||
{
|
||||
let _ = self.mavlink_errors.publish_record(record);
|
||||
}
|
||||
@@ -789,7 +789,7 @@ pub fn record_mavlink_completion(completion: kaptan_dma::TxCompletion) {
|
||||
}
|
||||
}
|
||||
|
||||
#[kaptan_err_propagate::propagate]
|
||||
#[kaptan_err_reportable::propagate]
|
||||
fn publish_lidar_event(
|
||||
event: LidarLiteV3ServiceEvent<I2c1Error>,
|
||||
) -> Result<(), LidarError<I2c1Error>> {
|
||||
@@ -810,14 +810,14 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn transient_i2c_busy_is_retry_not_a_typed_lidar_fault() {
|
||||
while kaptan_err_propagate::take().is_some() {}
|
||||
while kaptan_err_reportable::take().is_some() {}
|
||||
assert_eq!(
|
||||
publish_lidar_event(LidarLiteV3ServiceEvent::Fault(LidarError::Start(
|
||||
I2c1Error::Busy,
|
||||
))),
|
||||
Ok(())
|
||||
);
|
||||
assert!(kaptan_err_propagate::take().is_none());
|
||||
assert!(kaptan_err_reportable::take().is_none());
|
||||
|
||||
assert!(matches!(
|
||||
publish_lidar_event(LidarLiteV3ServiceEvent::Fault(LidarError::Start(
|
||||
@@ -825,7 +825,7 @@ mod tests {
|
||||
))),
|
||||
Err(LidarError::Start(I2c1Error::InvalidLength))
|
||||
));
|
||||
assert!(kaptan_err_propagate::take().is_some());
|
||||
assert!(kaptan_err_reportable::take().is_some());
|
||||
|
||||
assert!(matches!(
|
||||
publish_lidar_event(LidarLiteV3ServiceEvent::Fault(LidarError::Start(
|
||||
@@ -833,6 +833,6 @@ mod tests {
|
||||
))),
|
||||
Err(LidarError::Start(I2c1Error::InvalidAddress))
|
||||
));
|
||||
assert!(kaptan_err_propagate::take().is_some());
|
||||
assert!(kaptan_err_reportable::take().is_some());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//! STM32F722 Pll216 clock-source assembly.
|
||||
|
||||
use super::peripherals::{DwtMicrosecondClock, select_pll216_profile};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use stm32f7::stm32f722;
|
||||
|
||||
/// Core frequency in whole megahertz after selecting the PLL216 board profile.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Deterministic STM32F722 PLL clock-source selection.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use stm32f7::stm32f722;
|
||||
|
||||
const CLOCK_SWITCH_POLL_LIMIT: u16 = 1_024;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! STM32F722 I²C1 interrupt-driven controller.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_i2c::{I2cBus, I2cCompletion};
|
||||
use stm32f7::stm32f722;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! is generated after the last serial frame; transmit completion can occur
|
||||
//! while the final serial clock is still in progress.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_spi::SpiCompletion;
|
||||
use stm32f7::stm32f722;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! is generated after the last serial frame; transmit completion can occur
|
||||
//! while the final serial clock is still in progress.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_spi::SpiCompletion;
|
||||
use stm32f7::stm32f722;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! DWT-backed monotonic microsecond clock for STM32F722.
|
||||
|
||||
use cortex_m::peripheral::{DCB, DWT};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_time::{MonotonicClock, Timestamp};
|
||||
|
||||
/// A DWT cycle counter extended into monotonic microseconds.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! STM32F722 USART routes used by supported boards.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use stm32f7::stm32f722;
|
||||
|
||||
/// UART baud-rate configuration error.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! cannot be selected at construction.
|
||||
|
||||
use kaptan_dma::{DmaReadableBuffer, DmaTxEngine, TxCompletion};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use stm32f7::stm32f722;
|
||||
|
||||
use super::Usart1Tx;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//! cannot be selected at construction.
|
||||
|
||||
use kaptan_dma::{DmaReadableBuffer, DmaTxEngine, TxCompletion};
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use stm32f7::stm32f722;
|
||||
|
||||
use super::Usart2Tx;
|
||||
|
||||
@@ -5,7 +5,7 @@ use kaptan_drivers::{
|
||||
icm42688::{Error as Icm42688Error, Icm42688, Icm42688Service, Icm42688ServiceEvent},
|
||||
mpu6000::{Error as Mpu6000Error, Mpu6000, Mpu6000Config, Mpu6000Service, Mpu6000ServiceEvent},
|
||||
};
|
||||
use kaptan_err_propagate::{ErrorId, ErrorReport};
|
||||
use kaptan_err_reportable::{ErrorId, ReportableError};
|
||||
use kaptan_sensor::imu::ImuSnapshot;
|
||||
use kaptan_spi::SpiCompletion;
|
||||
use stm32f7::stm32f722;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#![no_std]
|
||||
|
||||
use kaptan_config::Config;
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
|
||||
pub use kaptan_drivers::mpu6000::{
|
||||
AccelerometerRange, DigitalLowPassFilter, GyroscopeRange, Mpu6000Config,
|
||||
|
||||
@@ -369,10 +369,10 @@ fn mavlink_transport_faults_do_not_recurse_or_retain_dead_accounting() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f722_producers_keep_logs_and_typed_errors_separate() {
|
||||
fn f722_producers_keep_logs_and_reportable_errors_separate() {
|
||||
let board = platform_source("src/f722/board.rs");
|
||||
let logger = platform_source("../../libs/kaptan-log/src/facade.rs");
|
||||
let errors = platform_source("../../libs/kaptan-err-propagate/src/ingress.rs");
|
||||
let errors = platform_source("../../libs/kaptan-err-reportable/src/ingress.rs");
|
||||
|
||||
for macro_name in [
|
||||
"kaptan_log::debug!",
|
||||
@@ -385,7 +385,7 @@ fn f722_producers_keep_logs_and_typed_errors_separate() {
|
||||
"f722 does not exercise {macro_name}"
|
||||
);
|
||||
}
|
||||
assert!(board.contains("#[kaptan_err_propagate::propagate]"));
|
||||
assert!(board.contains("#[kaptan_err_reportable::propagate]"));
|
||||
assert!(!board.contains("report_error"));
|
||||
assert!(!board.contains("report_static_error"));
|
||||
assert!(logger.contains("GLOBAL_INGRESS_CAPACITY"));
|
||||
|
||||
@@ -539,7 +539,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn packet_and_history_decode_a_typed_kaptan_error() {
|
||||
fn packet_and_history_decode_a_reportable_kaptan_error() {
|
||||
let raised_at_text = "platforms/stm32f7/src/f722/board.rs:572";
|
||||
let mut raised_at = [0; 96];
|
||||
raised_at[..raised_at_text.len()].copy_from_slice(raised_at_text.as_bytes());
|
||||
@@ -684,7 +684,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn malformed_typed_error_location_is_not_added_to_history() {
|
||||
fn malformed_reportable_error_location_is_not_added_to_history() {
|
||||
let mut raised_at = [0_u8; 96];
|
||||
raised_at[0] = 0xff;
|
||||
let mut frame = MavlinkFrame::new();
|
||||
|
||||
@@ -9,7 +9,7 @@ version.workspace = true
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
kaptan-err-propagate = { path = "../../libs/kaptan-err-propagate" }
|
||||
kaptan-err-reportable = { path = "../../libs/kaptan-err-reportable" }
|
||||
kaptan-control = { path = "../../libs/kaptan-control" }
|
||||
kaptan-config = { path = "../../libs/kaptan-config" }
|
||||
kaptan-config-mavlink = { path = "../../libs/kaptan-config-mavlink" }
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::{
|
||||
};
|
||||
|
||||
use kaptan_config::ConfigStore;
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use kaptan_flight_config::{
|
||||
CandidateProfile, CborEncodeError, CborError, MAXIMUM_CANDIDATE_BYTES, VehicleProfile,
|
||||
decode_candidate, encode_candidate,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//! dialect. It is confined to one host network namespace and is versioned so
|
||||
//! malformed simulator traffic never becomes estimator or motor authority.
|
||||
|
||||
use kaptan_err_propagate::KaptanError;
|
||||
use kaptan_err_reportable::KaptanError;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
pub const SENSOR_PORT: u16 = 14_660;
|
||||
|
||||
Reference in new issue
Block a user