Skip to content

Commit 9477838

Browse files
Update main.rs
Enhance error processing of command `request`
1 parent cf73b6e commit 9477838

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/main.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,15 @@ impl Executor {
11201120
// Send the http request
11211121
"request" => {
11221122
let url = self.pop_stack().get_string();
1123-
self.stack.push(Type::String(
1124-
reqwest::blocking::get(url).unwrap().text().unwrap(),
1125-
));
1123+
match reqwest::blocking::get(url) {
1124+
Ok(i) => self
1125+
.stack
1126+
.push(Type::String(i.text().unwrap_or("".to_string()))),
1127+
Err(e) => {
1128+
self.log_print(format!("Error! {e}\n"));
1129+
self.stack.push(Type::Error("request".to_string()))
1130+
}
1131+
}
11261132
}
11271133

11281134
// Open the file or url

0 commit comments

Comments
 (0)