Skip to content

Commit fd4259a

Browse files
committed
tree: move cass_error_desc to execution_error.rs
There existed an `external.rs` file that only contained the `cass_error_desc` function. As other error-related functions reside in `execution_error.rs`, it makes sense to move it there as well. The `external.rs` file is now deleted.
1 parent 0570dd7 commit fd4259a

File tree

5 files changed

+78
-85
lines changed

5 files changed

+78
-85
lines changed

scylla-rust-wrapper/src/api.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ pub mod error {
717717
CassError,
718718
CassErrorResult,
719719
CassErrorSource,
720+
cass_error_desc,
720721
cass_error_num_arg_types,
721722
cass_error_result_arg_type,
722723
cass_error_result_code,
@@ -731,12 +732,6 @@ pub mod error {
731732
cass_error_result_table,
732733
cass_error_result_write_type,
733734
};
734-
735-
// Disabling rustfmt to have one item per line for better readability.
736-
#[rustfmt::skip]
737-
pub use crate::external::{
738-
cass_error_desc,
739-
};
740735
}
741736

742737
pub mod iterator {

scylla-rust-wrapper/src/execution_error.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub use crate::cass_error::{CassError, CassErrorSource};
44
use crate::cass_error_types::CassWriteType;
55
use crate::cass_types::CassConsistency;
66
use crate::types::*;
7+
use libc::c_char;
78
use scylla::deserialize::DeserializationError;
89
use scylla::errors::{DbError, ExecutionError, RequestAttemptError, WriteType};
910
use scylla::frame::frame_errors::ResultMetadataAndRowsCountParseError;
@@ -350,3 +351,78 @@ pub unsafe extern "C" fn cass_error_result_arg_type(
350351
_ => CassError::CASS_ERROR_LIB_INVALID_ERROR_RESULT_TYPE,
351352
}
352353
}
354+
355+
#[unsafe(no_mangle)]
356+
pub unsafe extern "C" fn cass_error_desc(error: CassError) -> *const c_char {
357+
let desc = match error {
358+
CassError::CASS_ERROR_LIB_BAD_PARAMS => c"Bad parameters",
359+
CassError::CASS_ERROR_LIB_NO_STREAMS => c"No streams available",
360+
CassError::CASS_ERROR_LIB_UNABLE_TO_INIT => c"Unable to initialize",
361+
CassError::CASS_ERROR_LIB_MESSAGE_ENCODE => c"Unable to encode message",
362+
CassError::CASS_ERROR_LIB_HOST_RESOLUTION => c"Unable to resolve host",
363+
CassError::CASS_ERROR_LIB_UNEXPECTED_RESPONSE => c"Unexpected response from server",
364+
CassError::CASS_ERROR_LIB_REQUEST_QUEUE_FULL => c"The request queue is full",
365+
CassError::CASS_ERROR_LIB_NO_AVAILABLE_IO_THREAD => c"No available IO threads",
366+
CassError::CASS_ERROR_LIB_WRITE_ERROR => c"Write error",
367+
CassError::CASS_ERROR_LIB_NO_HOSTS_AVAILABLE => c"No hosts available",
368+
CassError::CASS_ERROR_LIB_INDEX_OUT_OF_BOUNDS => c"Index out of bounds",
369+
CassError::CASS_ERROR_LIB_INVALID_ITEM_COUNT => c"Invalid item count",
370+
CassError::CASS_ERROR_LIB_INVALID_VALUE_TYPE => c"Invalid value type",
371+
CassError::CASS_ERROR_LIB_REQUEST_TIMED_OUT => c"Request timed out",
372+
CassError::CASS_ERROR_LIB_UNABLE_TO_SET_KEYSPACE => c"Unable to set keyspace",
373+
CassError::CASS_ERROR_LIB_CALLBACK_ALREADY_SET => c"Callback already set",
374+
CassError::CASS_ERROR_LIB_INVALID_STATEMENT_TYPE => c"Invalid statement type",
375+
CassError::CASS_ERROR_LIB_NAME_DOES_NOT_EXIST => c"No value or column for name",
376+
CassError::CASS_ERROR_LIB_UNABLE_TO_DETERMINE_PROTOCOL => {
377+
c"Unable to find supported protocol version"
378+
}
379+
CassError::CASS_ERROR_LIB_NULL_VALUE => c"NULL value specified",
380+
CassError::CASS_ERROR_LIB_NOT_IMPLEMENTED => c"Not implemented",
381+
CassError::CASS_ERROR_LIB_UNABLE_TO_CONNECT => c"Unable to connect",
382+
CassError::CASS_ERROR_LIB_UNABLE_TO_CLOSE => c"Unable to close",
383+
CassError::CASS_ERROR_LIB_NO_PAGING_STATE => c"No paging state",
384+
CassError::CASS_ERROR_LIB_PARAMETER_UNSET => c"Parameter unset",
385+
CassError::CASS_ERROR_LIB_INVALID_ERROR_RESULT_TYPE => c"Invalid error result type",
386+
CassError::CASS_ERROR_LIB_INVALID_FUTURE_TYPE => c"Invalid future type",
387+
CassError::CASS_ERROR_LIB_INTERNAL_ERROR => c"Internal error",
388+
CassError::CASS_ERROR_LIB_INVALID_CUSTOM_TYPE => c"Invalid custom type",
389+
CassError::CASS_ERROR_LIB_INVALID_DATA => c"Invalid data",
390+
CassError::CASS_ERROR_LIB_NOT_ENOUGH_DATA => c"Not enough data",
391+
CassError::CASS_ERROR_LIB_INVALID_STATE => c"Invalid state",
392+
CassError::CASS_ERROR_LIB_NO_CUSTOM_PAYLOAD => c"No custom payload",
393+
CassError::CASS_ERROR_LIB_EXECUTION_PROFILE_INVALID => {
394+
c"Invalid execution profile specified"
395+
}
396+
CassError::CASS_ERROR_LIB_NO_TRACING_ID => c"No tracing ID",
397+
CassError::CASS_ERROR_SERVER_SERVER_ERROR => c"Server error",
398+
CassError::CASS_ERROR_SERVER_PROTOCOL_ERROR => c"Protocol error",
399+
CassError::CASS_ERROR_SERVER_BAD_CREDENTIALS => c"Bad credentials",
400+
CassError::CASS_ERROR_SERVER_UNAVAILABLE => c"Unavailable",
401+
CassError::CASS_ERROR_SERVER_OVERLOADED => c"Overloaded",
402+
CassError::CASS_ERROR_SERVER_IS_BOOTSTRAPPING => c"Is bootstrapping",
403+
CassError::CASS_ERROR_SERVER_TRUNCATE_ERROR => c"Truncate error",
404+
CassError::CASS_ERROR_SERVER_WRITE_TIMEOUT => c"Write timeout",
405+
CassError::CASS_ERROR_SERVER_READ_TIMEOUT => c"Read timeout",
406+
CassError::CASS_ERROR_SERVER_READ_FAILURE => c"Read failure",
407+
CassError::CASS_ERROR_SERVER_FUNCTION_FAILURE => c"Function failure",
408+
CassError::CASS_ERROR_SERVER_WRITE_FAILURE => c"Write failure",
409+
CassError::CASS_ERROR_SERVER_SYNTAX_ERROR => c"Syntax error",
410+
CassError::CASS_ERROR_SERVER_UNAUTHORIZED => c"Unauthorized",
411+
CassError::CASS_ERROR_SERVER_INVALID_QUERY => c"Invalid query",
412+
CassError::CASS_ERROR_SERVER_CONFIG_ERROR => c"Configuration error",
413+
CassError::CASS_ERROR_SERVER_ALREADY_EXISTS => c"Already exists",
414+
CassError::CASS_ERROR_SERVER_UNPREPARED => c"Unprepared",
415+
CassError::CASS_ERROR_SSL_INVALID_CERT => c"Unable to load certificate",
416+
CassError::CASS_ERROR_SSL_INVALID_PRIVATE_KEY => c"Unable to load private key",
417+
CassError::CASS_ERROR_SSL_NO_PEER_CERT => c"No peer certificate",
418+
CassError::CASS_ERROR_SSL_INVALID_PEER_CERT => c"Invalid peer certificate",
419+
CassError::CASS_ERROR_SSL_IDENTITY_MISMATCH => {
420+
c"Certificate does not match host or IP address"
421+
}
422+
CassError::CASS_ERROR_SSL_PROTOCOL_ERROR => c"Protocol error",
423+
CassError::CASS_ERROR_SSL_CLOSED => c"Connection closed",
424+
_ => c"",
425+
};
426+
427+
desc.as_ptr()
428+
}

scylla-rust-wrapper/src/external.rs

Lines changed: 0 additions & 77 deletions
This file was deleted.

scylla-rust-wrapper/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pub(crate) mod config_value;
2020
pub(crate) mod date_time;
2121
pub(crate) mod exec_profile;
2222
pub(crate) mod execution_error;
23-
mod external;
2423
pub(crate) mod future;
2524
pub(crate) mod inet;
2625
#[cfg(cpp_integration_testing)]

scylla-rust-wrapper/src/testing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ pub(crate) fn setup_tracing() {
77

88
macro_rules! assert_cass_error_eq {
99
($expr:expr, $error:expr $(,)?) => {{
10+
use crate::api::error::cass_error_desc;
1011
use crate::argconv::ptr_to_cstr;
11-
use crate::external::cass_error_desc;
1212
let ___x = $expr;
1313
assert_eq!(
1414
___x,

0 commit comments

Comments
 (0)