Skip to content

Commit dbecfa8

Browse files
fix(cli): catch errors from url.set_scheme()
Signed-off-by: Kevin W Matthews <[email protected]>
1 parent d06defa commit dbecfa8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

crates/ilp-cli/src/interpreter.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ pub enum Error {
1616
ResponseErr(String),
1717
#[fail(display = "Error parsing URL protocol: {}", _0)]
1818
ProtocolErr(&'static str),
19+
#[fail(display = "Error altering URL scheme")]
20+
SchemeErr(),
1921
#[fail(display = "Error parsing URL: {}", _0)]
2022
UrlErr(url::ParseError),
2123
#[fail(display = "Error connecting to WebSocket host: {}", _0)]
@@ -144,8 +146,9 @@ impl NodeClient<'_> {
144146
_ => Err(Error::ProtocolErr("Unexpected protocol")),
145147
}?;
146148

147-
// The scheme has already been sanitized so this should always succeed
148-
url.set_scheme(scheme).expect("Could not alter URL scheme");
149+
if url.set_scheme(scheme).is_err() {
150+
return Err(Error::SchemeErr());
151+
};
149152

150153
let mut request: Request = url.into();
151154
request.add_header(

0 commit comments

Comments
 (0)