Skip to content

Commit 7c21bd7

Browse files
committed
display error cause on github
1 parent 30656d6 commit 7c21bd7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/server/routes/agent.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::server::{Data, HttpError};
88
use failure::Compat;
99
use http::{Response, StatusCode};
1010
use hyper::Body;
11+
use std::collections::HashMap;
1112
use std::sync::Arc;
1213
use warp::{self, Filter, Rejection};
1314

@@ -156,7 +157,11 @@ fn endpoint_heartbeat(data: Arc<Data>, auth: AuthDetails) -> Fallible<Response<B
156157
Ok(ApiResponse::Success { result: true }.into_response()?)
157158
}
158159

159-
fn endpoint_error(error: String, data: Arc<Data>, auth: AuthDetails) -> Fallible<Response<Body>> {
160+
fn endpoint_error(
161+
error: HashMap<String, String>,
162+
data: Arc<Data>,
163+
auth: AuthDetails,
164+
) -> Fallible<Response<Body>> {
160165
let ex = Experiment::run_by(&data.db, &Assignee::Agent(auth.name.clone()))?
161166
.ok_or_else(|| err_msg("no experiment run by this agent"))?;
162167

@@ -165,11 +170,14 @@ fn endpoint_error(error: String, data: Arc<Data>, auth: AuthDetails) -> Fallible
165170
.line(
166171
"exclamation",
167172
format!(
168-
"Experiment **`{}`** **running** on agent `{}` has encountered an error",
173+
"Experiment **`{}`** running on agent `{}` has encountered an error",
169174
ex.name, auth.name,
170175
),
171176
)
172-
.line("", format!("error: {}", error,))
177+
.line(
178+
"sos",
179+
format!("caused by: {}", error.get("error").unwrap(),),
180+
)
173181
.send(&github_issue.api_url, &data)?;
174182
}
175183
Ok(ApiResponse::Success { result: true }.into_response()?)

0 commit comments

Comments
 (0)