Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions engine/packages/error/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
use crate::INTERNAL_ERROR;
use crate::schema::RivetErrorSchema;
use serde::Serialize;
use std::{fmt, sync::OnceLock};

static EXPOSE_INTERNAL_ERRORS: OnceLock<bool> = OnceLock::new();

fn expose_internal_errors() -> bool {
*EXPOSE_INTERNAL_ERRORS
.get_or_init(|| matches!(std::env::var("RIVET_EXPOSE_ERRORS").as_deref(), Ok("1")))
}
use std::fmt;

#[derive(Debug, Clone)]
pub struct RivetError {
Expand Down Expand Up @@ -36,7 +29,7 @@ impl RivetError {
Self {
schema: &INTERNAL_ERROR,
meta,
message: expose_internal_errors().then(|| format!("Internal error: {}", error)),
message: Some(format!("{}", error)),
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"code": "query_failed",
"group": "sqlite",
"message": "SQL query failed."
}
6 changes: 5 additions & 1 deletion rivetkit-rust/packages/rivetkit-core/src/actor/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,11 @@ fn map_local_worker_error(error: anyhow::Error) -> anyhow::Error {
return SqliteRuntimeError::Closed.build();
}

error
// User SQL errors (syntax, constraints, etc.)
SqliteRuntimeError::QueryFailed {
message: format!("{error}"),
}
.build()
}

fn protocol_bind_params(params: Vec<BindParam>) -> Vec<protocol::SqliteBindParam> {
Expand Down
4 changes: 4 additions & 0 deletions rivetkit-rust/packages/rivetkit-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub fn public_error_status_code(group: &str, code: &str) -> Option<u16> {
| "complete_not_configured"
| "timed_out",
) => Some(400),
("sqlite", "query_failed") => Some(400),
_ => None,
}
}
Expand Down Expand Up @@ -192,6 +193,9 @@ pub(crate) enum SqliteRuntimeError {
"Remote SQLite generation is stale: {reason}"
)]
RemoteFenceMismatch { reason: String },

#[error("query_failed", "SQL query failed.", "SQL query failed: {message}")]
QueryFailed { message: String },
}

#[derive(RivetError, Debug, Clone, Deserialize, Serialize)]
Expand Down
Loading