Skip to content

Commit 14a15bc

Browse files
committed
improve run_sql invalid variables error message
1 parent 8165795 commit 14a15bc

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/webserver/database/sqlpage_functions/functions.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,8 @@ async fn run_sql<'a>(
570570
.await
571571
.with_context(|| format!("run_sql: invalid path {sql_file_path:?}"))?;
572572
let tmp_req = if let Some(variables) = variables {
573-
let variables: ParamMap = serde_json::from_str(&variables).map_err(|err| {
574-
let context = format!(
575-
"run_sql: unable to parse the variables argument (line {}, column {})",
576-
err.line(),
577-
err.column()
578-
);
579-
anyhow::Error::new(err).context(context)
573+
let variables: ParamMap = serde_json::from_str(&variables).with_context(|| {
574+
format!("run_sql(\'{sql_file_path}\', \'{variables}\'): the second argument should be a JSON object with string keys and values")
580575
})?;
581576
request.fork_with_variables(variables)
582577
} else {

0 commit comments

Comments
 (0)