Skip to content

Commit c87b93c

Browse files
author
Devdutt Shenoi
authored
refactor: use appropriate error types (#1201)
1 parent 5e3577f commit c87b93c

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/event/mod.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ use itertools::Itertools;
2525
use std::sync::Arc;
2626

2727
use self::error::EventError;
28-
use crate::{metadata::update_stats, parseable::PARSEABLE, storage::StreamType, LOCK_EXPECT};
28+
use crate::{
29+
metadata::update_stats,
30+
parseable::{StagingError, PARSEABLE},
31+
storage::StreamType,
32+
LOCK_EXPECT,
33+
};
2934
use chrono::NaiveDateTime;
3035
use std::collections::HashMap;
3136

@@ -109,7 +114,7 @@ pub fn get_schema_key(fields: &[Arc<Field>]) -> String {
109114
format!("{hash:x}")
110115
}
111116

112-
pub fn commit_schema(stream_name: &str, schema: Arc<Schema>) -> Result<(), EventError> {
117+
pub fn commit_schema(stream_name: &str, schema: Arc<Schema>) -> Result<(), StagingError> {
113118
let mut stream_metadata = PARSEABLE.streams.write().expect("lock poisoned");
114119

115120
let map = &mut stream_metadata
@@ -127,16 +132,13 @@ pub fn commit_schema(stream_name: &str, schema: Arc<Schema>) -> Result<(), Event
127132
}
128133

129134
pub mod error {
130-
use arrow_schema::ArrowError;
131135

132136
use crate::{parseable::StagingError, storage::ObjectStorageError};
133137

134138
#[derive(Debug, thiserror::Error)]
135139
pub enum EventError {
136-
#[error("Stream Writer Failed: {0}")]
137-
StreamWriter(#[from] StagingError),
138-
#[error("Stream Writer Failed: {0}")]
139-
Arrow(#[from] ArrowError),
140+
#[error("Staging Failed: {0}")]
141+
Staging(#[from] StagingError),
140142
#[error("ObjectStorage Error: {0}")]
141143
ObjectStorage(#[from] ObjectStorageError),
142144
}

src/handlers/http/query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub async fn get_counts(
167167
}))
168168
}
169169

170-
pub async fn update_schema_when_distributed(tables: &Vec<String>) -> Result<(), QueryError> {
170+
pub async fn update_schema_when_distributed(tables: &Vec<String>) -> Result<(), EventError> {
171171
if PARSEABLE.options.mode == Mode::Query {
172172
for table in tables {
173173
if let Ok(new_schema) = fetch_schema(table).await {
@@ -304,7 +304,7 @@ pub enum QueryError {
304304
Execute(#[from] ExecuteError),
305305
#[error("ObjectStorage Error: {0}")]
306306
ObjectStorage(#[from] ObjectStorageError),
307-
#[error("Evern Error: {0}")]
307+
#[error("Event Error: {0}")]
308308
EventError(#[from] EventError),
309309
#[error("Error: {0}")]
310310
MalformedQuery(&'static str),

0 commit comments

Comments
 (0)