A tool to compile SQL to Elasticsearch queries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

error.rs 577B

12345678910111213141516171819202122232425262728
  1. use std::{error::Error, fmt, fmt::Display};
  2. #[derive(Debug, PartialEq)]
  3. pub struct KappeError {
  4. pub message: String,
  5. }
  6. impl KappeError {
  7. pub fn new(message: &str) -> Self {
  8. Self {
  9. message: message.to_string(),
  10. }
  11. }
  12. }
  13. impl Display for KappeError {
  14. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
  15. write!(f, "{}", &self.message)
  16. }
  17. }
  18. impl Error for KappeError {}
  19. impl From<KappeError> for std::io::Error {
  20. fn from(e: KappeError) -> Self {
  21. Self::new(std::io::ErrorKind::InvalidInput, e.message)
  22. }
  23. }