Skip to content

Commit

Permalink
Merge pull request #25 from interlay/greg/fix/vault-exit
Browse files Browse the repository at this point in the history
fix(vault): prettier exit response
  • Loading branch information
sander2 authored Mar 3, 2021
2 parents b7cf1e9 + f735625 commit 821a609
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 2 additions & 0 deletions vault/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use thiserror::Error;

#[derive(Error, Debug)]
pub enum Error {
#[error("Internal error")]
InternalError,
#[error("Insufficient funds available")]
InsufficientFunds,
#[error("Open time inconsistent with chain height")]
Expand Down
12 changes: 4 additions & 8 deletions vault/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,10 @@ pub async fn start<B: BitcoinCoreApi + Send + Sync + 'static>(
}),
);
match result {
Ok(_) => {
println!("Done");
}
Ok(_) => Ok(()),
Err(err) => {
println!("Error: {}", err);
std::process::exit(1);
error!("{:?}", err);
Err(Error::InternalError)
}
};

Ok(())
}
}
18 changes: 14 additions & 4 deletions vault/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ use runtime::substrate_subxt::PairSigner;
use runtime::{PolkaBtcProvider, PolkaBtcRuntime};
use std::sync::Arc;
use std::time::Duration;
use vault::{start, Error, Opts};
use vault::{Error, Opts};

#[tokio::main]
async fn main() -> Result<(), Error> {
async fn start() -> Result<(), Error> {
env_logger::init();
let opts: Opts = Opts::parse();
let intact_opts = opts.clone();
Expand Down Expand Up @@ -43,5 +42,16 @@ async fn main() -> Result<(), Error> {
.await?,
);

start(intact_opts, provider, btc_rpc).await
vault::start(intact_opts, provider, btc_rpc).await
}

#[tokio::main]
async fn main() {
let exit_code = if let Err(err) = start().await {
eprintln!("Error: {}", err);
1
} else {
0
};
std::process::exit(exit_code);
}

0 comments on commit 821a609

Please sign in to comment.