Skip to content

Commit 470cf0c

Browse files
committed
Have handle_triage and handle_compare return ServerResult
Follows the convention for handlers which have an associated `api::xxx::Response` object.
1 parent 91b6d27 commit 470cf0c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

site/src/comparison.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ type BoxedError = Box<dyn Error + Send + Sync>;
2222
pub async fn handle_triage(
2323
body: api::triage::Request,
2424
ctxt: &SiteCtxt,
25-
) -> Result<api::triage::Response, BoxedError> {
25+
) -> api::ServerResult<api::triage::Response> {
2626
let start = body.start;
2727
let end = body.end;
28-
let master_commits = collector::master_commits().await?;
28+
let master_commits = collector::master_commits()
29+
.await
30+
.map_err(|e| format!("error retrieving master commit list: {}", e))?;
2931

3032
let start_artifact = ctxt
3133
.artifact_id_for_bound(start.clone(), true)
@@ -47,7 +49,8 @@ pub async fn handle_triage(
4749
&master_commits,
4850
body.calcNewSig.unwrap_or(false),
4951
)
50-
.await?
52+
.await
53+
.map_err(|e| format!("error comparing commits: {}", e))?
5154
{
5255
Some(c) => c,
5356
None => {
@@ -87,8 +90,10 @@ pub async fn handle_triage(
8790
pub async fn handle_compare(
8891
body: api::comparison::Request,
8992
ctxt: &SiteCtxt,
90-
) -> Result<api::comparison::Response, BoxedError> {
91-
let master_commits = collector::master_commits().await?;
93+
) -> api::ServerResult<api::comparison::Response> {
94+
let master_commits = collector::master_commits()
95+
.await
96+
.map_err(|e| format!("error retrieving master commit list: {}", e))?;
9297
let end = body.end;
9398
let comparison = compare_given_commits(
9499
body.start,
@@ -98,7 +103,8 @@ pub async fn handle_compare(
98103
&master_commits,
99104
body.calcNewSig.unwrap_or(false),
100105
)
101-
.await?
106+
.await
107+
.map_err(|e| format!("error comparing commits: {}", e))?
102108
.ok_or_else(|| format!("could not find end commit for bound {:?}", end))?;
103109

104110
let conn = ctxt.conn().await;

0 commit comments

Comments
 (0)