Skip to content

Instantly share code, notes, and snippets.

@joaoh82
Created February 23, 2021 09:33
Show Gist options
  • Save joaoh82/95c46f176ce62c51e36c32b7ac92f9ff to your computer and use it in GitHub Desktop.
Save joaoh82/95c46f176ce62c51e36c32b7ac92f9ff to your computer and use it in GitHub Desktop.
SQLRite - error module - Part 2
use thiserror::Error;
use std::{result};
use sqlparser::parser::ParserError;
pub type Result<T> = result::Result<T, SQLRiteError>;
#[derive(Error, Debug, PartialEq)]
pub enum SQLRiteError {
#[error("Not Implemented error: {0}")]
NotImplemented(String),
#[error("General error: {0}")]
General(String),
#[error("Internal error: {0}")]
Internal(String),
#[error("Unknown command error: {0}")]
UnknownCommand(String),
#[error("SQL error: {0:?}")]
SqlError(#[from] ParserError),
}
/// Return SQLRite errors from String
pub fn sqlrite_error(message: &str) -> SQLRiteError {
SQLRiteError::General(message.to_owned())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment