diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3977c51..7dae3b74 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -149,7 +149,7 @@ jobs: fi for test_binary in "${test_binaries[@]}"; do echo "::group::$(basename "$test_binary")" - "$test_binary" + "$test_binary" --quiet echo "::endgroup::" done env: diff --git a/src/webserver/database/error_highlighting.rs b/src/webserver/database/error_highlighting.rs index 0080607d..b457ec99 100644 --- a/src/webserver/database/error_highlighting.rs +++ b/src/webserver/database/error_highlighting.rs @@ -95,6 +95,10 @@ impl std::error::Error for NicePositionedError { } } +pub(super) fn is_positioned_error(error: &anyhow::Error) -> bool { + error.downcast_ref::().is_some() +} + /// Display a database error without any position information #[must_use] pub(super) fn display_db_error( diff --git a/src/webserver/database/execute_queries.rs b/src/webserver/database/execute_queries.rs index 2bf6f647..9154afeb 100644 --- a/src/webserver/database/execute_queries.rs +++ b/src/webserver/database/execute_queries.rs @@ -8,7 +8,7 @@ use std::pin::Pin; use tracing::Instrument; use super::csv_import::run_csv_import; -use super::error_highlighting::{display_stmt_db_error, display_stmt_error}; +use super::error_highlighting::{display_stmt_db_error, display_stmt_error, is_positioned_error}; use super::sql::{ DatabaseQuery, FileStatement, OutputColumn, Query, QueryBody, SingleRowQuery, SourceSpan, SqlFile, @@ -301,7 +301,7 @@ fn with_stmt_position( query_position: SourceSpan, error: anyhow::Error, ) -> anyhow::Error { - if error.downcast_ref::().is_some() { + if error.downcast_ref::().is_some() || is_positioned_error(&error) { error } else { display_stmt_error(source_file, query_position, error) @@ -321,11 +321,10 @@ pub fn stop_at_first_error( results_stream .inspect(move |item| { - if let DbItem::Error(err) = item { - log::error!("{err:?}"); - if let Some(tx) = error_tx.take() { - let _ = tx.send(()); - } + if matches!(item, DbItem::Error(_)) + && let Some(tx) = error_tx.take() + { + let _ = tx.send(()); } }) .take_until(error_rx) diff --git a/src/webserver/database/sqlpage_functions/functions/run_sql.rs b/src/webserver/database/sqlpage_functions/functions/run_sql.rs index 6de31f52..31f6a638 100644 --- a/src/webserver/database/sqlpage_functions/functions/run_sql.rs +++ b/src/webserver/database/sqlpage_functions/functions/run_sql.rs @@ -75,7 +75,7 @@ pub(super) async fn run_sql<'a>( } FinishedQuery => log::trace!("run_sql: Finished query"), Error(err) => { - return Err(err.context(format!("run_sql: unable to run {sql_file_path:?}"))); + return Err(err); } } } diff --git a/tests/sql_test_files/mod.rs b/tests/sql_test_files/mod.rs index 915cc0cc..c8cf53f3 100644 --- a/tests/sql_test_files/mod.rs +++ b/tests/sql_test_files/mod.rs @@ -257,6 +257,13 @@ fn assert_html_test(body: &str, test_file: &std::path::Path, stem: &str) { expected, test_file.display() ); + if stem == "error_too_many_nested_inclusions" { + assert!( + !body.contains("run_sql: unable to run"), + "Recursive inclusion error should not repeat run_sql context: {}", + test_file.display() + ); + } } else { if let Some(error) = extract_error(body) { panic!("Error in {}: {}", test_file.display(), error);