@@ -96,117 +96,132 @@ mod private
9696 /// helps in defining such results more concisely.
9797 pub type ResultWithReport < Report , Error > = Result < Report , ( Report , Error ) > ;
9898
99- ///
100- /// Macro to generate an error descriptor.
101- ///
102- /// ### Basic use-case.
103- /// ```rust
104- /// # use error_tools::{ BasicError, err };
105- /// fn f1() -> BasicError
106- /// {
107- /// return err!( "No attr" );
108- /// }
109- /// ```
110- ///
111-
112- #[ macro_export ]
113- macro_rules! err
114- {
115-
116- ( $msg : expr ) =>
117- {
118- $crate:: BasicError :: new( $msg ) . into( )
119- } ;
120- ( $msg : expr, $( $arg : expr ) ,+ $( , ) ? ) =>
121- {
122- $crate:: BasicError :: new( format!( $msg, $( $arg ) ,+ ) ) . into( )
123- } ;
124-
125- }
126-
127- ///
128- /// Macro to return an Err( error ) generating error descriptor.
129- ///
130- /// ### Basic use-case.
131- /// ```rust
132- /// # use error_tools::{ BasicError, return_err };
133- /// fn f1() -> Result< (), BasicError >
134- /// {
135- /// return_err!( "No attr" );
136- /// }
137- /// ```
138- ///
139-
140- #[ macro_export ]
141- macro_rules! return_err
142- {
143-
144- ( $msg : expr ) =>
145- {
146- return Result :: Err ( $crate:: err!( $msg ) )
147- } ;
148- ( $msg : expr, $( $arg : expr ) ,+ $( , ) ? ) =>
149- {
150- return Result :: Err ( $crate:: err!( $msg, $( $arg ) ,+ ) )
151- } ;
152-
153- }
154-
155- // zzz : review
156-
157- /// baic implementation of generic BasicError
158-
159- #[ derive( core:: fmt:: Debug , core:: clone:: Clone , core:: cmp:: PartialEq , core:: cmp:: Eq ) ]
160- pub struct BasicError
161- {
162- msg : String ,
163- }
164-
165- impl BasicError
166- {
167- /// Constructor expecting message with description.
168- pub fn new < Msg : Into < String > > ( msg : Msg ) -> BasicError
169- {
170- BasicError { msg : msg. into ( ) }
171- }
172- /// Message with description getter.
173- pub fn msg ( & self ) -> & String
174- {
175- & self . msg
176- }
177- }
99+ // ///
100+ // /// Macro to generate an error descriptor.
101+ // ///
102+ // /// ### Basic use-case.
103+ // /// ```rust
104+ // /// # use error_tools::{ BasicError, err };
105+ // /// fn f1() -> BasicError
106+ // /// {
107+ // /// return err!( "No attr" );
108+ // /// }
109+ // /// ```
110+ // ///
111+ //
112+ // #[ macro_export ]
113+ // macro_rules! err
114+ // {
115+ //
116+ // ( $msg : expr ) =>
117+ // {
118+ // $crate::BasicError::new( $msg ).into()
119+ // };
120+ // ( $msg : expr, $( $arg : expr ),+ $(,)? ) =>
121+ // {
122+ // $crate::BasicError::new( format!( $msg, $( $arg ),+ ) ).into()
123+ // };
124+ //
125+ // }
126+ //
127+ // ///
128+ // /// Macro to return an Err( error ) generating error descriptor.
129+ // ///
130+ // /// ### Basic use-case.
131+ // /// ```rust
132+ // /// # use error_tools::{ BasicError, return_err };
133+ // /// fn f1() -> Result< (), BasicError >
134+ // /// {
135+ // /// return_err!( "No attr" );
136+ // /// }
137+ // /// ```
138+ // ///
139+ //
140+ // #[ macro_export ]
141+ // macro_rules! return_err
142+ // {
143+ //
144+ // ( $msg : expr ) =>
145+ // {
146+ // return Result::Err( $crate::err!( $msg ) )
147+ // };
148+ // ( $msg : expr, $( $arg : expr ),+ $(,)? ) =>
149+ // {
150+ // return Result::Err( $crate::err!( $msg, $( $arg ),+ ) )
151+ // };
152+ //
153+ // }
154+ //
155+ // // zzz : review
156+ // // xxx : rid of
157+ //
158+ // /// baic implementation of generic BasicError
159+ //
160+ // #[ derive( core::fmt::Debug, core::clone::Clone, core::cmp::PartialEq, core::cmp::Eq ) ]
161+ // pub struct BasicError
162+ // {
163+ // msg : String,
164+ // }
165+ //
166+ // impl BasicError
167+ // {
168+ // /// Constructor expecting message with description.
169+ // pub fn new< Msg : Into< String > >( msg : Msg ) -> BasicError
170+ // {
171+ // BasicError { msg : msg.into() }
172+ // }
173+ // /// Message with description getter.
174+ // pub fn msg( &self ) -> &String
175+ // {
176+ // &self.msg
177+ // }
178+ // }
179+ //
180+ // impl core::fmt::Display for BasicError
181+ // {
182+ // fn fmt(&self, f: &mut core::fmt::Formatter< '_ >) -> core::fmt::Result
183+ // {
184+ // write!( f, "{}", self.msg )
185+ // }
186+ // }
187+ //
188+ // impl ErrorTrait for BasicError
189+ // {
190+ // fn description( &self ) -> &str
191+ // {
192+ // &self.msg
193+ // }
194+ // }
195+ //
196+ // impl< T > From< BasicError > for Result< T, BasicError >
197+ // {
198+ // /// Returns the argument unchanged.
199+ // #[ inline( always ) ]
200+ // fn from( src : BasicError ) -> Self
201+ // {
202+ // Result::Err( src )
203+ // }
204+ // }
205+ //
206+ // pub use err;
207+ // pub use return_err;
178208
179- impl core:: fmt:: Display for BasicError
180- {
181- fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result
182- {
183- write ! ( f, "{}" , self . msg )
184- }
185- }
186-
187- impl ErrorTrait for BasicError
188- {
189- fn description ( & self ) -> & str
190- {
191- & self . msg
192- }
193- }
209+ // qqq : write standard mod interface without using mod_interface /* aaa : Dmytro : added to each library file */
210+ }
194211
195- impl < T > From < BasicError > for Result < T , BasicError >
196- {
197- /// Returns the argument unchanged.
198- #[ inline( always ) ]
199- fn from ( src : BasicError ) -> Self
200- {
201- Result :: Err ( src )
202- }
203- }
212+ /// Assertions.
213+ #[ cfg( feature = "enabled" ) ]
214+ pub mod assert;
204215
205- pub use err;
206- pub use return_err;
216+ #[ cfg( feature = "enabled" ) ]
217+ #[ cfg( feature = "error_typed" ) ]
218+ /// Typed exceptions handling mechanism.
219+ pub mod typed;
207220
208- // qqq : write standard mod interface without using mod_interface /* aaa : Dmytro : added to each library file */
209- }
221+ #[ cfg( feature = "enabled" ) ]
222+ #[ cfg( feature = "error_untyped" ) ]
223+ /// Untyped exceptions handling mechanism.
224+ pub mod untyped;
210225
211226#[ doc( inline ) ]
212227#[ allow( unused_imports ) ]
@@ -217,8 +232,37 @@ pub use own::*;
217232pub mod own
218233{
219234 use super :: * ;
235+
220236 #[ doc( inline ) ]
221237 pub use orphan:: * ;
238+
239+ #[ doc( inline ) ]
240+ pub use assert:: orphan:: * ;
241+
242+ #[ cfg( feature = "error_untyped" ) ]
243+ #[ doc( inline ) ]
244+ pub use untyped:: orphan:: * ;
245+
246+ #[ cfg( feature = "error_typed" ) ]
247+ #[ doc( inline ) ]
248+ pub use typed:: orphan:: * ;
249+
250+ #[ doc( inline ) ]
251+ pub use private::
252+ {
253+ // err,
254+ // return_err,
255+ ErrorTrait ,
256+ // BasicError,
257+ } ;
258+
259+ pub use super ::
260+ {
261+ assert,
262+ typed,
263+ untyped,
264+ } ;
265+
222266}
223267
224268/// Shared with parent namespace of the module
@@ -236,6 +280,9 @@ pub mod exposed
236280{
237281 use super :: * ;
238282
283+ #[ doc( inline ) ]
284+ pub use prelude:: * ;
285+
239286 #[ doc( inline ) ]
240287 pub use private::
241288 {
@@ -244,7 +291,16 @@ pub mod exposed
244291 } ;
245292
246293 #[ doc( inline ) ]
247- pub use prelude:: * ;
294+ pub use assert:: exposed:: * ;
295+
296+ #[ cfg( feature = "error_untyped" ) ]
297+ #[ doc( inline ) ]
298+ pub use untyped:: exposed:: * ;
299+
300+ #[ cfg( feature = "error_typed" ) ]
301+ #[ doc( inline ) ]
302+ pub use typed:: exposed:: * ;
303+
248304}
249305
250306/// Prelude to use essentials: `use my_module::prelude::*`.
@@ -253,13 +309,24 @@ pub mod prelude
253309{
254310 use super :: * ;
255311
312+ // #[ doc( inline ) ]
313+ // pub use private::
314+ // {
315+ // // err,
316+ // // return_err,
317+ // ErrorTrait,
318+ // // BasicError,
319+ // };
320+
256321 #[ doc( inline ) ]
257- pub use private::
258- {
259- err,
260- return_err,
261- ErrorTrait ,
262- BasicError ,
263- } ;
322+ pub use assert:: prelude:: * ;
323+
324+ #[ cfg( feature = "error_untyped" ) ]
325+ #[ doc( inline ) ]
326+ pub use untyped:: prelude:: * ;
327+
328+ #[ cfg( feature = "error_typed" ) ]
329+ #[ doc( inline ) ]
330+ pub use typed:: prelude:: * ;
264331
265332}
0 commit comments