Skip to content

Commit e99f1ee

Browse files
refactor: return result for borscontext::new
1 parent 58a9565 commit e99f1ee

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/bin/bors.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ fn try_main(opts: Opts) -> anyhow::Result<()> {
7575
create_github_client(opts.app_id.into(), opts.private_key.into_bytes().into())
7676
})?;
7777

78-
let ctx = runtime.block_on(BorsContext::new(
79-
CommandParser::new(opts.cmd_prefix),
80-
Arc::new(db),
81-
Arc::new(client),
82-
));
78+
let ctx = runtime
79+
.block_on(BorsContext::new(
80+
CommandParser::new(opts.cmd_prefix),
81+
Arc::new(db),
82+
Arc::new(client),
83+
))
84+
.context("Cannot initialize bors context")?;
8385
let (repository_tx, global_tx, bors_process) = create_bors_process(ctx);
8486

8587
let refresh_tx = global_tx.clone();

src/bors/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ impl<Client: RepositoryClient> BorsContext<Client> {
1717
parser: CommandParser,
1818
db: Arc<dyn DbClient>,
1919
global_client: Arc<dyn GlobalClient<Client>>,
20-
) -> Self {
20+
) -> anyhow::Result<Self> {
2121
// this unwrap is making me nervous, but if lhe repos loading
2222
// fails we might as well restart the bot
23-
let repositories = global_client.load_repositories().await.unwrap();
23+
let repositories = global_client.load_repositories().await?;
2424
let repositories = Arc::new(ArcSwap::new(Arc::new(repositories)));
25-
Self {
25+
Ok(Self {
2626
parser,
2727
db,
2828
global_client,
2929
repositories,
30-
}
30+
})
3131
}
3232
}

src/tests/state.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ impl TestBorsState {
7272
Arc::clone(&self.db) as Arc<dyn DbClient>,
7373
Arc::new(self.default_client.clone()),
7474
)
75-
.await,
75+
.await
76+
.unwrap(),
7677
);
7778
match event {
7879
BorsEvent::Repository(event) => {

0 commit comments

Comments
 (0)