Skip to content

Commit a1a8628

Browse files
author
Eric Swanson
committed
errors after fns
1 parent 58a2532 commit a1a8628

File tree

10 files changed

+137
-150
lines changed

10 files changed

+137
-150
lines changed

bin/icp-cli/src/commands.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ pub enum Subcmd {
1515
Network(network::Cmd),
1616
}
1717

18-
#[derive(Debug, Snafu)]
19-
pub enum DispatchError {
20-
#[snafu(transparent)]
21-
Network { source: NetworkCommandError },
22-
}
23-
2418
pub async fn dispatch(cli: Cli) -> Result<(), DispatchError> {
2519
match cli.subcommand {
2620
Subcmd::Network(opts) => network::dispatch(opts).await?,
2721
}
2822
Ok(())
2923
}
24+
25+
#[derive(Debug, Snafu)]
26+
pub enum DispatchError {
27+
#[snafu(transparent)]
28+
Network { source: NetworkCommandError },
29+
}

bin/icp-cli/src/commands/network.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::commands::network::run::RunNetworkError;
1+
use crate::commands::network::run::RunNetworkCommandError;
22
use clap::{Parser, Subcommand};
33
use snafu::Snafu;
44

@@ -15,14 +15,15 @@ pub enum Subcmd {
1515
Run(run::Cmd),
1616
}
1717

18-
#[derive(Debug, Snafu)]
19-
pub enum NetworkCommandError {
20-
#[snafu(transparent)]
21-
Run { source: RunNetworkError },
22-
}
2318
pub async fn dispatch(cmd: Cmd) -> Result<(), NetworkCommandError> {
2419
match cmd.subcmd {
2520
Subcmd::Run(cmd) => run::exec(cmd).await?,
2621
}
2722
Ok(())
2823
}
24+
25+
#[derive(Debug, Snafu)]
26+
pub enum NetworkCommandError {
27+
#[snafu(transparent)]
28+
Run { source: RunNetworkCommandError },
29+
}
Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,16 @@
1+
use crate::commands::network::run::RunNetworkCommandError::ProjectStructureNotFound;
12
use crate::project::structure::ProjectDirectoryStructure;
23
use clap::Parser;
3-
use icp_network::{ManagedNetworkModel, StartLocalNetworkError, run_network};
4+
use icp_network::{ManagedNetworkModel, RunNetworkError, run_network};
45
use snafu::Snafu;
56

67
/// Run the local network
78
#[derive(Parser, Debug)]
89
pub struct Cmd {}
910

10-
#[derive(Debug, Snafu)]
11-
pub enum RunNetworkError {
12-
#[snafu(display("no project (icp.yaml) found in current directory or its parents"))]
13-
ProjectStructureNotFound,
14-
15-
#[snafu(transparent)]
16-
NetworkExecutionFailed { source: StartLocalNetworkError },
17-
}
18-
19-
pub async fn exec(_cmd: Cmd) -> Result<(), RunNetworkError> {
11+
pub async fn exec(_cmd: Cmd) -> Result<(), RunNetworkCommandError> {
2012
let config = ManagedNetworkModel::default();
21-
let ps = ProjectDirectoryStructure::find().ok_or(RunNetworkError::ProjectStructureNotFound)?;
13+
let ps = ProjectDirectoryStructure::find().ok_or(ProjectStructureNotFound)?;
2214
eprintln!("Project root: {}", ps.root().display());
2315

2416
let nds = ps.network("local");
@@ -28,3 +20,12 @@ pub async fn exec(_cmd: Cmd) -> Result<(), RunNetworkError> {
2820

2921
Ok(())
3022
}
23+
24+
#[derive(Debug, Snafu)]
25+
pub enum RunNetworkCommandError {
26+
#[snafu(display("no project (icp.yaml) found in current directory or its parents"))]
27+
ProjectStructureNotFound,
28+
29+
#[snafu(transparent)]
30+
NetworkExecutionFailed { source: RunNetworkError },
31+
}

lib/icp-fs/src/directories.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

lib/icp-fs/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
pub mod directories;
21
pub mod fs;
32
pub mod json;

lib/icp-network/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ pub mod structure;
55

66
pub use config::model::managed::ManagedNetworkModel;
77
pub use config::model::network_config::NetworkConfig;
8-
pub use managed::run::StartLocalNetworkError;
8+
pub use managed::run::RunNetworkError;
99
pub use managed::run::run_network;

lib/icp-network/src/managed/pocketic/admin.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,6 @@ pub struct PocketIcAdminInterface {
1313
base_url: Url,
1414
}
1515

16-
#[derive(Debug, Snafu)]
17-
pub enum CreateInstanceError {
18-
#[snafu(
19-
display("failed to create PocketIC instance: {message}"),
20-
context(suffix(InstanceSnafu))
21-
)]
22-
Create { message: String },
23-
24-
#[snafu(transparent)]
25-
Reqwest { source: reqwest::Error },
26-
}
27-
28-
#[derive(Debug, Snafu)]
29-
pub enum CreateHttpGatewayError {
30-
#[snafu(
31-
display("failed to create HTTP gateway: {message}"),
32-
context(suffix(GatewaySnafu))
33-
)]
34-
Create { message: String },
35-
36-
#[snafu(transparent, context(false))]
37-
Reqwest { source: reqwest::Error },
38-
}
39-
4016
impl PocketIcAdminInterface {
4117
pub fn new(base_url: Url) -> Self {
4218
let client = reqwest::Client::new();
@@ -143,3 +119,27 @@ impl PocketIcAdminInterface {
143119
}
144120
}
145121
}
122+
123+
#[derive(Debug, Snafu)]
124+
pub enum CreateInstanceError {
125+
#[snafu(
126+
display("failed to create PocketIC instance: {message}"),
127+
context(suffix(InstanceSnafu))
128+
)]
129+
Create { message: String },
130+
131+
#[snafu(transparent)]
132+
Reqwest { source: reqwest::Error },
133+
}
134+
135+
#[derive(Debug, Snafu)]
136+
pub enum CreateHttpGatewayError {
137+
#[snafu(
138+
display("failed to create HTTP gateway: {message}"),
139+
context(suffix(GatewaySnafu))
140+
)]
141+
Create { message: String },
142+
143+
#[snafu(transparent, context(false))]
144+
Reqwest { source: reqwest::Error },
145+
}

0 commit comments

Comments
 (0)