Skip to content

Commit

Permalink
Check LSP status range (#644)
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyGiorgio committed Jul 6, 2023
1 parent f1c7ea0 commit 51165d8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mutiny-core/src/lspclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,16 @@ impl LspClient {
.await
.map_err(|_| MutinyError::LspGenericError)?;

if response.status().as_u16() == 200 {
let status = response.status().as_u16();
if (200..300).contains(&status) {
let proposal_response: ProposalResponse = response
.json()
.await
.map_err(|_| MutinyError::LspGenericError)?;

return Ok(proposal_response.jit_bolt11);
} else {
// If it's not a 200 status, copy the response body to a string and try to parse as ErrorResponse
} else if response.status().as_u16() >= 400 {
// If it's not OK, copy the response body to a string and try to parse as ErrorResponse
let response_body = response
.text()
.await
Expand Down

0 comments on commit 51165d8

Please sign in to comment.