Skip to content

Commit

Permalink
再展開時のハンドリングが間違っている部分を修正した
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryoga Saito committed Dec 2, 2023
1 parent 8e08881 commit 41fdac4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
10 changes: 6 additions & 4 deletions src/bot/commands/redeploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,13 @@ impl Bot {
.await?;
},
Err(err) => match err {
RedeployError::AnotherJobInQueue(_) => {
RedeployError::AnotherJobInQueue => {
self.edit_response(component_interaction, |response| {
response.content("再展開中の問題があります。他の問題の再展開が完了してから再度お試しください。")
})
.await?;
response.content(
"この問題は既に再展開リクエストが投げられています。再展開が完了してから再度お試しください。",
)
})
.await?;
},

_ => {
Expand Down
15 changes: 6 additions & 9 deletions src/services/redeploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub enum RedeployError {
#[error("invalid parameters")]
InvalidParameters,
#[error("another job is in queue")]
AnotherJobInQueue(String),
AnotherJobInQueue,

// serde_jsonでserialize/deserializeに失敗した時に出るエラー
#[error("serde_json error: {0}")]
Expand Down Expand Up @@ -150,16 +150,13 @@ impl RedeployService for RState {
problem_code: response.prob_id,
})
},
StatusCode::BAD_REQUEST => {
let data = String::from_utf8(response.bytes().await?.to_vec())
.map_err(|err| RedeployError::Unexpected(Box::new(err)))?;

if data == "BadRequest!" {
return Err(RedeployError::InvalidParameters);
}
// ref: https://github.com/ictsc/rstate/blob/main/pkg/server/handler/status.go#L121-L124
StatusCode::BAD_REQUEST => Err(RedeployError::InvalidParameters),

// ref: https://github.com/ictsc/rstate/blob/main/pkg/server/handler/status.go#L145C65-L148
StatusCode::CONFLICT => Err(RedeployError::AnotherJobInQueue),

Err(RedeployError::AnotherJobInQueue(data))
},
_ => Err(RedeployError::Unexpected(
anyhow::anyhow!("unexpected status code: {}", response.status()).into(),
)),
Expand Down

0 comments on commit 41fdac4

Please sign in to comment.