]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Better error handling
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 22 Nov 2024 15:26:04 +0000 (16:26 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 11 Feb 2025 15:28:22 +0000 (16:28 +0100)
pdns/recursordist/settings/rust/src/web.rs
pdns/recursordist/ws-recursor.cc

index 8151c1a3ac25dfaa6bc138737f20e97f3f398aa0..d934f21456090ed0dfd04121555a6a595d90effd 100644 (file)
@@ -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);
             }
         }
     }
index b4fb291ea77802f9f14131dbba25491d817b7f11..7a1a326198f9adb366d4145ea64937e0d016452d 100644 (file)
@@ -993,6 +993,12 @@ static void rustWrapper(const std::function<void(HttpRequest*, HttpResponse*)>&
     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);
 }