Skip to content

Commit

Permalink
fixing cyclic dependency problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Wandalen committed Nov 5, 2024
1 parent f0a6898 commit f92c46f
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 53 deletions.
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -536,4 +536,14 @@ version = "0.1.83"
[workspace.dependencies.tokio]
version = "1.41.0"
features = []
default-features = false
default-features = false

[workspace.dependencies.anyhow]
version = "~1.0"
# features = []
# default-features = false

[workspace.dependencies.thiserror]
version = "~1.0"
# features = []
# default-features = false
5 changes: 3 additions & 2 deletions module/core/error_tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ error_untyped = [ "anyhow" ]
# = entry

[dependencies]
anyhow = { version = "~1.0", optional = true }
thiserror = { version = "~1.0", optional = true }
anyhow = { workspace = true, optional = true }
thiserror = { workspace = true, optional = true }

[dev-dependencies]
test_tools = { workspace = true }
# xxx : qqq : review
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,13 @@ pub mod typed;
/// Untyped exceptions handling mechanism.
pub mod untyped;

#[ cfg( feature = "enabled" ) ]
#[ doc( inline ) ]
#[ allow( unused_imports ) ]
pub use own::*;

/// Own namespace of the module.
#[ cfg( feature = "enabled" ) ]
#[ allow( unused_imports ) ]
pub mod own
{
Expand Down Expand Up @@ -256,16 +258,16 @@ pub mod own
// BasicError,
};

pub use super::
{
assert,
typed,
untyped,
};
pub use super::assert;
#[ cfg( feature = "error_typed" ) ]
pub use super::typed;
#[ cfg( feature = "error_untyped" ) ]
pub use super::untyped;

}

/// Shared with parent namespace of the module
#[ cfg( feature = "enabled" ) ]
#[ allow( unused_imports ) ]
pub mod orphan
{
Expand All @@ -275,6 +277,7 @@ pub mod orphan
}

/// Exposed namespace of the module.
#[ cfg( feature = "enabled" ) ]
#[ allow( unused_imports ) ]
pub mod exposed
{
Expand Down Expand Up @@ -304,6 +307,7 @@ pub mod exposed
}

/// Prelude to use essentials: `use my_module::prelude::*`.
#[ cfg( feature = "enabled" ) ]
#[ allow( unused_imports ) ]
pub mod prelude
{
Expand Down
21 changes: 16 additions & 5 deletions module/core/test_tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ all-features = false
# = features

[features]
default = [ "enabled" ]
full = [ "enabled" ]
default = [
"enabled",
"error_typed",
"error_untyped",
]
full = [ "default" ]
no_std = [
# "error_tools/no_std",
# "meta_tools/no_std",
Expand Down Expand Up @@ -62,20 +66,22 @@ enabled = [
]
# nightly = [ "typing_tools/nightly" ]

error_typed = []
error_untyped = []

[dependencies]

## external

paste = "~1.0" # zzz : remove laster
# paste = "~1.0" # zzz : remove later
rustversion = "~1.0"
# anyhow = "~1.0"
num-traits = "~0.2"
trybuild = { version = "1.0.85", features = [ "diff" ] }
rand = "0.8.5"

## internal

error_tools = { workspace = true, features = [ "full" ] }
# error_tools = { workspace = true, features = [ "full" ] }
meta_tools = { workspace = true, features = [ "full" ] }
mem_tools = { workspace = true, features = [ "full" ] }
typing_tools = { workspace = true, features = [ "full" ] }
Expand All @@ -86,5 +92,10 @@ collection_tools = { workspace = true, features = [ "full" ] }

# former_stable = { workspace = true, features = [ "full" ] }

## transient

anyhow = { workspace = true }
thiserror = { workspace = true }

[build-dependencies]
rustc_version = "0.4"
10 changes: 5 additions & 5 deletions module/core/test_tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
pub mod dependency
{

// zzz : exclude later
#[ doc( inline ) ]
pub use ::paste;
// // zzz : exclude later
// #[ doc( inline ) ]
// pub use ::paste;
#[ doc( inline ) ]
pub use ::trybuild;
#[ doc( inline ) ]
Expand Down Expand Up @@ -41,8 +41,8 @@ pub mod dependency

}

// #[ path = "../../../core/error_tools/src/lib.rs" ]
// pub mod error_tools;
#[ path = "../../../core/error_tools/src/error/mod.rs" ]
pub mod error_tools;

mod private {}

Expand Down
6 changes: 3 additions & 3 deletions module/move/willbe/src/action/cicd_renew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod private
use error::
{
typed::Error,
err,
// err,
};

#[ derive( Debug, Error ) ]
Expand Down Expand Up @@ -375,7 +375,7 @@ mod private
return url::repo_url_extract( &url )
.and_then( | url | url::git_info_extract( &url ).ok() )
.map( UsernameAndRepository )
.ok_or_else( || err!( "Fail to parse repository url from workspace Cargo.toml"))
.ok_or_else( || error::untyped::format_err!( "Fail to parse repository url from workspace Cargo.toml"))
}
else
{
Expand All @@ -393,7 +393,7 @@ mod private
.and_then( | url | url::repo_url_extract( &url ) )
.and_then( | url | url::git_info_extract( &url ).ok() )
.map( UsernameAndRepository )
.ok_or_else( || err!( "Fail to extract repository url") )
.ok_or_else( || error::untyped::format_err!( "Fail to extract repository url") )
}
}

Expand Down
6 changes: 3 additions & 3 deletions module/move/willbe/src/action/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod private
};
use error::
{
ErrWith, err,
ErrWith,
untyped::{ Context, format_err },
};
use tool::{ TreePrinter, ListNodeReport };
Expand All @@ -39,7 +39,7 @@ mod private
{
"tree" => ListFormat::Tree,
"toposort" => ListFormat::Topological,
e => return Err( err!( "Unknown format '{}'. Available values : [tree, toposort]", e ))
e => return Err( error::untyped::format_err!( "Unknown format '{}'. Available values : [tree, toposort]", e ))
};

Ok( value )
Expand Down Expand Up @@ -105,7 +105,7 @@ mod private
{
"nothing" => ListFilter::Nothing,
"local" => ListFilter::Local,
e => return Err( err!( "Unknown filter '{}'. Available values : [nothing, local]", e ) )
e => return Err( error::untyped::format_err!( "Unknown filter '{}'. Available values : [nothing, local]", e ) )
};

Ok( value )
Expand Down
14 changes: 7 additions & 7 deletions module/move/willbe/src/action/main_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ mod private
use entity::{ PathError, WorkspaceInitError };
use error::
{
err,
untyped::Error,
// err,
// untyped::Error,
};
use workspace_md_extension::WorkspaceMdExtension;

Expand Down Expand Up @@ -86,7 +86,7 @@ mod private
{
/// Represents a common error.
#[ error( "Common error: {0}" ) ]
Common(#[ from ] Error ),
Common( #[ from ] error::untyped::Error ), // qqq : rid of
/// Represents an I/O error.
#[ error( "I/O error: {0}" ) ]
IO( #[ from ] std::io::Error ),
Expand Down Expand Up @@ -116,14 +116,14 @@ mod private
// aaa : done
let repository_url = workspace
.repository_url()
.ok_or_else::< Error, _ >
( || err!( "repo_url not found in workspace Cargo.toml" ) )?;
.ok_or_else::< error::untyped::Error, _ >
( || error::untyped::format_err!( "repo_url not found in workspace Cargo.toml" ) )?;

let master_branch = workspace.master_branch().unwrap_or( "master".into() );
let workspace_name = workspace
.workspace_name()
.ok_or_else::< Error, _ >
( || err!( "workspace_name not found in workspace Cargo.toml" ) )?;
.ok_or_else::< error::untyped::Error, _ >
( || error::untyped::format_err!( "workspace_name not found in workspace Cargo.toml" ) )?;

let discord_url = workspace.discord_url();

Expand Down
12 changes: 6 additions & 6 deletions module/move/willbe/src/action/readme_modules_headers_renew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ mod private
use package::Package;
use error::
{
err,
// err,
untyped::
{
// Result,
Error as wError,
// Error as wError,
Context,
},
};
Expand Down Expand Up @@ -101,7 +101,7 @@ mod private
{
/// Represents a common error.
#[ error( "Common error: {0}" ) ]
Common(#[ from ] wError ),
Common(#[ from ] error::untyped::Error ), // qqq : rid of
/// Represents an I/O error.
#[ error( "I/O error: {0}" ) ]
IO( #[ from ] std::io::Error ),
Expand Down Expand Up @@ -140,7 +140,7 @@ mod private
let stability = package.stability()?;
let module_name = package.name()?;
let repository_url = package.repository()?
.ok_or_else::< wError, _ >( || err!( "Fail to find repository_url in module`s Cargo.toml" ) )?;
.ok_or_else::< error::untyped::Error, _ >( || error::untyped::format_err!( "Fail to find repository_url in module`s Cargo.toml" ) )?;

let discord_url = package
.discord_url()?
Expand Down Expand Up @@ -172,7 +172,7 @@ mod private

let repo_url = url::repo_url_extract( &self.repository_url )
.and_then( | r | url::git_info_extract( &r ).ok() )
.ok_or_else::< wError, _ >( || err!( "Fail to parse repository url" ) )?;
.ok_or_else::< error::untyped::Error, _ >( || error::untyped::format_err!( "Fail to parse repository url" ) )?;
let example= if let Some( name ) = find_example_file
(
self.module_path.as_path(),
Expand Down Expand Up @@ -269,7 +269,7 @@ mod private
.join
(
repository::readme_path( path.parent().unwrap().as_ref() )
// .ok_or_else::< wError, _ >( || err!( "Fail to find README.md at {}", &path ) )
// .ok_or_else::< error::untyped::Error, _ >( || error::untyped::format_err!( "Fail to find README.md at {}", &path ) )
.err_with_report( &report )?
);

Expand Down
4 changes: 2 additions & 2 deletions module/move/willbe/src/command/readme_headers_renew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod private
{
use crate::*;
use action;
use error::{ err };
// use error::{ err };
use std::fmt::{ Display, Formatter };

#[ derive( Debug, Default ) ]
Expand Down Expand Up @@ -103,7 +103,7 @@ mod private
if fail
{
eprintln!( "{report}" );
Err( err!( "Something went wrong" ) )
Err( error::untyped::format_err!( "Something went wrong" ) )
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion module/move/willbe/src/entity/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mod private
.bin_path( program )
.args( options.into_iter().map( OsString::from ).collect::< Vec< _ > >() )
.current_path( path.as_ref().to_path_buf() )
.run().map_err::< Error, _ >( | report | err!( report.to_string() ) )?;
.run().map_err::< Error, _ >( | report | error::untyped::format_err!( report.to_string() ) )?;

let list = report
.out
Expand Down
10 changes: 5 additions & 5 deletions module/move/willbe/src/tool/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ mod private

use std::ffi::OsString;
use std::path::PathBuf;
use error::err;
use error::untyped::format_err;
// use error::err;
// use error::untyped::format_err;
use former::Former;
use process_tools::process;
// use process_tools::process::*;
Expand Down Expand Up @@ -118,7 +118,7 @@ mod private
.bin_path( program )
.args( options.into_iter().map( OsString::from ).collect::< Vec< _ > >() )
.current_path( args.path )
.run().map_err( | report | err!( report.to_string() ) )
.run().map_err( | report | error::untyped::format_err!( report.to_string() ) )
}
}

Expand Down Expand Up @@ -197,11 +197,11 @@ mod private
}
if args.retry_count > 0
{
Err( format_err!( "It took {} attempts, but still failed. Here are the errors:\n{}", args.retry_count + 1, results.into_iter().map( | r | format!( "- {r}" ) ).collect::< Vec< _ > >().join( "\n" ) ) )
Err( error::untyped::format_err!( "It took {} attempts, but still failed. Here are the errors:\n{}", args.retry_count + 1, results.into_iter().map( | r | format!( "- {r}" ) ).collect::< Vec< _ > >().join( "\n" ) ) )
}
else
{
Err( results.remove( 0 ) ).map_err( | report | err!( report.to_string() ) )
Err( results.remove( 0 ) ).map_err( | report | error::untyped::format_err!( report.to_string() ) )
}
}
}
Expand Down
Loading

0 comments on commit f92c46f

Please sign in to comment.