I've stumbled upon a fact that some errors (like connection one for example) are not particularly helpful:
$ cat src/main.rs
use surf::Config;
use surf::Client;
use surf::Result;
use surf::Url;
#[async_std::main]
async fn main() -> Result<()> {
let url = Url::parse("http://127.0.0.1:8080")?;
let http: Client = Config::new().set_base_url(url).try_into()?;
if let Err(e) = http.post("/endpoint").body_json(&String::from("{}"))?.await {
eprintln!("test-prg: cannot make POST request to http://127.0.0.1:8080/endpoint: {}", e);
}
Ok(())
}
$ cargo build --bin test-prg
$ ./target/debug/test-prg
test-prg: cannot make POST request to http://127.0.0.1:8080/endpoint: An error occured while creating a new object: Connection refused (os error 111)
I think it would be better either to report only the status code so the user could add the required context:
Connection refused (os error 111)
or to report something like
Cannot connect to 127.0.0.1 port 8080: Connection refused (os error 111)
Hi,
I've stumbled upon a fact that some errors (like connection one for example) are not particularly helpful:
I think it would be better either to report only the status code so the user could add the required context:
or to report something like