From: Otto Moerbeek Date: Fri, 22 Nov 2024 15:26:04 +0000 (+0100) Subject: Better error handling X-Git-Tag: dnsdist-2.0.0-alpha1~95^2~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7319430a2fcc0edf38317f86e9ee723bc792854a;p=thirdparty%2Fpdns.git Better error handling --- diff --git a/pdns/recursordist/settings/rust/src/web.rs b/pdns/recursordist/settings/rust/src/web.rs index 8151c1a3ac..d934f21456 100644 --- a/pdns/recursordist/settings/rust/src/web.rs +++ b/pdns/recursordist/settings/rust/src/web.rs @@ -266,13 +266,13 @@ async fn hello( } let pos = urls.iter().position(|x| String::from("/") + x == path); if pos.is_none() { - println!("{} not found", path); + eprintln!("{} {} not found", rust_request.method(), path); } if rustweb::serveStuff(&request, &mut response).is_err() { // Return 404 not found response. response.status = StatusCode::NOT_FOUND.as_u16(); response.body = NOTFOUND.to_vec(); - println!("{} not found case 2", path); + eprintln!("{} {} not found case 2", rust_request.method(), path); } } } diff --git a/pdns/recursordist/ws-recursor.cc b/pdns/recursordist/ws-recursor.cc index b4fb291ea7..7a1a326198 100644 --- a/pdns/recursordist/ws-recursor.cc +++ b/pdns/recursordist/ws-recursor.cc @@ -993,6 +993,12 @@ static void rustWrapper(const std::function& response.body = e.response().body; response.status = e.response().status; } + catch (const ApiException & e) { + response.setErrorResult(e.what(), 422); + } + catch (const JsonException & e) { + response.setErrorResult(e.what(), 422); + } fromCxxToRust(response, rustResponse); }