diff --git a/integration_tests/base_routes.py b/integration_tests/base_routes.py index 48ed13c32..29ec66ebb 100644 --- a/integration_tests/base_routes.py +++ b/integration_tests/base_routes.py @@ -276,6 +276,16 @@ def file_download_async(): return serve_file(file_path) +@app.get("/sync/raise") +def sync_raise(): + raise Exception() + + +@app.get("/async/raise") +async def async_raise(): + raise Exception() + + if __name__ == "__main__": app.add_request_header("server", "robyn") current_file_path = pathlib.Path(__file__).parent.resolve() diff --git a/integration_tests/test_status_code.py b/integration_tests/test_status_code.py index 6a865b3e0..607ccf23b 100644 --- a/integration_tests/test_status_code.py +++ b/integration_tests/test_status_code.py @@ -21,3 +21,13 @@ def test_307_get_request(session): def test_int_status_code(session): r = requests.get(f"{BASE_URL}/int_status_code") assert r.status_code == 202 + + +def test_sync_500_internal_server_error(session): + r = requests.get(f"{BASE_URL}/sync/raise") + assert r.status_code == 500 + + +def test_async_500_internal_server_error(session): + r = requests.get(f"{BASE_URL}/async/raise") + assert r.status_code == 500 diff --git a/src/executors/mod.rs b/src/executors/mod.rs index 7ce5e0706..9c55de36e 100644 --- a/src/executors/mod.rs +++ b/src/executors/mod.rs @@ -68,7 +68,7 @@ pub async fn execute_http_function(request: &Request, function: FunctionInfo) -> }) } else { Python::with_gil(|py| -> Result { - let output = get_function_output(&function, py, request).unwrap(); + let output = get_function_output(&function, py, request)?; output.extract().context("Failed to get route response") }) }