diff --git a/scylla-rust-wrapper/src/cass_error.rs b/scylla-rust-wrapper/src/cass_error.rs index 06ab321c..f173caf9 100644 --- a/scylla-rust-wrapper/src/cass_error.rs +++ b/scylla-rust-wrapper/src/cass_error.rs @@ -3,6 +3,7 @@ use scylla::transport::errors::*; // Re-export error types. pub(crate) use crate::cass_error_types::{CassError, CassErrorSource}; use crate::query_error::CassErrorResult; +use crate::statement::UnknownNamedParameterError; pub trait ToCassError { fn to_cass_error(&self) -> CassError; @@ -94,7 +95,14 @@ impl ToCassError for BadQuery { BadQuery::ValuesTooLongForKey(_usize, _usize2) => CassError::CASS_ERROR_LAST_ENTRY, BadQuery::BadKeyspaceName(_bad_keyspace_name) => CassError::CASS_ERROR_LAST_ENTRY, BadQuery::Other(_other_query) => CassError::CASS_ERROR_LAST_ENTRY, - BadQuery::SerializationError(_) => CassError::CASS_ERROR_LAST_ENTRY, + BadQuery::SerializationError(e) => { + if e.downcast_ref::().is_some() { + // It means that our custom `UnknownNamedParameterError` was returned. + CassError::CASS_ERROR_LIB_NAME_DOES_NOT_EXIST + } else { + CassError::CASS_ERROR_LAST_ENTRY + } + } BadQuery::TooManyQueriesInBatchStatement(_) => CassError::CASS_ERROR_LAST_ENTRY, // BadQuery is non_exhaustive // For now, since all other variants return LAST_ENTRY, diff --git a/tests/src/integration/tests/test_named_parameters.cpp b/tests/src/integration/tests/test_named_parameters.cpp index ff4e71dd..4bcf182e 100644 --- a/tests/src/integration/tests/test_named_parameters.cpp +++ b/tests/src/integration/tests/test_named_parameters.cpp @@ -204,7 +204,7 @@ CASSANDRA_INTEGRATION_TEST_F(NamedParametersTests, SimpleStatementInvalidName) { insert_statement.bind("named_uuid", value_uuid_); insert_statement.bind("named_blob", value_blob_); insert_statement.bind >("named_list_floats", value_list_floats_); - EXPECT_EQ(CASS_ERROR_SERVER_INVALID_QUERY, + EXPECT_EQ(CASS_ERROR_LIB_NAME_DOES_NOT_EXIST, session_.execute(insert_statement, false).error_code()); }