v0.7.0
Changelog
[0.7.0] - 2024-03-27
- Added
context::Timeout
- Added
attachment::DisplayDuration
- Added
Reportable::with_type_status
- Added
ClearResult
trait for mappingOk(T)
->Ok(())
andErr(E)
->Err(())
types respectively
Add expect_field!
macro #6
Added expect_field!
macro:
https://github.com/knox-networks/bigerror/blob/93b087f0ee8447b55ceb67efd980711d0c6cfba6/src/lib.rs#L982-L988
the above expect_field!
invocation desugars into:
// ...
let my_field = bigerror::OptionReport::ok_or_not_found_field(my_struct.my_field, "my_field")?;
// ...
- added
FrError
- added
SetupError
- added
just printerr <test::uri>
to show the error trace of a given unit test - refactored
bigerror::__field
macro to handle optional methods:my_struct.my_field.as_ref()
Rename OptionReport
methods #7
Breaking change that renames OptionReport
methods:
pub trait OptionReport {
type Some;
- fn ok_or_not_found(self) -> Result<Self::Some, Report<NotFound>>;
- fn ok_or_not_found_kv<K, V>(self, key: K, value: V) -> Result<Self::Some, Report<NotFound>>
+ fn expect_or(self) -> Result<Self::Some, Report<NotFound>>;
+ fn expect_kv<K, V>(self, key: K, value: V) -> Result<Self::Some, Report<NotFound>>
where
K: Display,
V: Display;
- fn ok_or_not_found_field(self, field: &'static str) -> Result<Self::Some, Report<NotFound>>;
- fn ok_or_not_found_by<K: Display>(self, key: K) -> Result<Self::Some, Report<NotFound>>;
+ fn expect_field(self, field: &'static str) -> Result<Self::Some, Report<NotFound>>;
+ fn expect_by<K: Display>(self, key: K) -> Result<Self::Some, Report<NotFound>>;
}
OptionReport::expect_or
was used to avoid namespace conflicts withOption::expect
- This should align it with
expect_*
macros such asbigerror::expect_field!(my_struct.my_field)?;
Introduce typed key/value attachments #8
-
Added
KeyValue
attachment, now used inReportable::with_kv
andAttachExt::attach_kv
:
https://github.com/knox-networks/bigerror/blob/d27dea90f456d382ef678e866de8af77d9519f9e/src/attachment.rs#L18-L27 -
Refactored
Field
attachment:
https://github.com/knox-networks/bigerror/blob/d27dea90f456d382ef678e866de8af77d9519f9e/src/attachment.rs#L30-L37 -
Added
Type
attachment:
https://github.com/knox-networks/bigerror/blob/d27dea90f456d382ef678e866de8af77d9519f9e/src/attachment.rs#L50-L59 -
*_debug
methods renamed to use the*_dbg
shorthand
Add accessor method handling for expect_field!
, ResultIntoContext
trait additions #9
ResultIntoContext
trait:
- added
ResultIntoContext::then_ctx
andResultIntoContext::map_ctx
, equivalent toResult::and_then
andResult::map
for results where the error isReport<impl Reportable>
https://github.com/knox-networks/bigerror/blob/19b176fc03490f80621e6d56de0cb4982d9b5078/src/lib.rs#L128-L138
expect_field!
macro:
- accessor methods can now be treated as fields by prepending the method name with
%
:
https://github.com/knox-networks/bigerror/blob/6892246c8cfa4c6e5247daeba55f10de5635b7cd/src/lib.rs#L986
The above codeblock expands to:bigerror::OptionReport::expect_field(my_struct.my_field(), "my_field")
Added new contexts:
EncodeError
DecodeError
AuthError
InvalidState
- Added
attachment::FromTo
- Added
Reportable::attach_variant
Added LogError::on_err