Skip to content

Commit

Permalink
f_errors: remove TryFromInt variant from ParseError
Browse files Browse the repository at this point in the history
We removed last usages of this variant from scylla-proxy.
This allows us to remove the variant.
In the following commit, we will remove ParseError.
  • Loading branch information
muzarski committed Aug 27, 2024
1 parent 21f5867 commit e777860
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 1 addition & 4 deletions scylla-cql/src/frame/frame_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ pub enum FrameSerializationError {
}

#[derive(Error, Debug)]
pub enum ParseError {
#[error(transparent)]
TryFromIntError(#[from] std::num::TryFromIntError),
}
pub enum ParseError {}

#[non_exhaustive]
#[derive(Error, Debug, Clone)]
Expand Down
11 changes: 7 additions & 4 deletions scylla-proxy/src/frame.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use bytes::{Buf, BufMut, Bytes, BytesMut};
use scylla_cql::frame::frame_errors::{FrameDeserializationError, ParseError};
use scylla_cql::frame::frame_errors::FrameDeserializationError;
use scylla_cql::frame::protocol_features::ProtocolFeatures;
pub use scylla_cql::frame::request::RequestOpcode;
use scylla_cql::frame::request::{Request, RequestDeserializationError};
Expand Down Expand Up @@ -87,7 +87,7 @@ impl ResponseFrame {
request_params: FrameParams,
error: DbError,
msg: Option<&str>,
) -> Result<Self, ParseError> {
) -> Result<Self, std::num::TryFromIntError> {
let msg = msg.unwrap_or("Proxy-triggered error.");
let len_bytes = (msg.len() as u16).to_be_bytes(); // string len is a short in CQL protocol
let code_bytes = error.code(&ProtocolFeatures::default()).to_be_bytes(); // TODO: configurable features
Expand All @@ -111,7 +111,7 @@ impl ResponseFrame {
pub fn forged_supported(
request_params: FrameParams,
options: &HashMap<String, Vec<String>>,
) -> Result<Self, ParseError> {
) -> Result<Self, std::num::TryFromIntError> {
let mut buf = BytesMut::new();
types::write_string_multimap(options, &mut buf)?;

Expand Down Expand Up @@ -144,7 +144,10 @@ impl ResponseFrame {
}
}

fn serialize_error_specific_fields(buf: &mut BytesMut, error: DbError) -> Result<(), ParseError> {
fn serialize_error_specific_fields(
buf: &mut BytesMut,
error: DbError,
) -> Result<(), std::num::TryFromIntError> {
match error {
DbError::Unavailable {
consistency,
Expand Down

0 comments on commit e777860

Please sign in to comment.