Skip to content

refactor: use appropriate error types #1201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025
Merged
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
16 changes: 9 additions & 7 deletions src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ use itertools::Itertools;
use std::sync::Arc;

use self::error::EventError;
use crate::{metadata::update_stats, parseable::PARSEABLE, storage::StreamType, LOCK_EXPECT};
use crate::{
metadata::update_stats,
parseable::{StagingError, PARSEABLE},
storage::StreamType,
LOCK_EXPECT,
};
use chrono::NaiveDateTime;
use std::collections::HashMap;

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

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

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

pub mod error {
use arrow_schema::ArrowError;

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

#[derive(Debug, thiserror::Error)]
pub enum EventError {
#[error("Stream Writer Failed: {0}")]
StreamWriter(#[from] StagingError),
#[error("Stream Writer Failed: {0}")]
Arrow(#[from] ArrowError),
#[error("Staging Failed: {0}")]
Staging(#[from] StagingError),
#[error("ObjectStorage Error: {0}")]
ObjectStorage(#[from] ObjectStorageError),
}
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/http/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub async fn get_counts(
}))
}

pub async fn update_schema_when_distributed(tables: &Vec<String>) -> Result<(), QueryError> {
pub async fn update_schema_when_distributed(tables: &Vec<String>) -> Result<(), EventError> {
if PARSEABLE.options.mode == Mode::Query {
for table in tables {
if let Ok(new_schema) = fetch_schema(table).await {
Expand Down Expand Up @@ -304,7 +304,7 @@ pub enum QueryError {
Execute(#[from] ExecuteError),
#[error("ObjectStorage Error: {0}")]
ObjectStorage(#[from] ObjectStorageError),
#[error("Evern Error: {0}")]
#[error("Event Error: {0}")]
EventError(#[from] EventError),
#[error("Error: {0}")]
MalformedQuery(&'static str),
Expand Down
Loading