use std::error::Error;
use std::fmt;
use std::fmt::Formatter;
use thiserror::Error;
#[derive(Error, Debug)]
pub struct PgEmbedError {
pub error_type: PgEmbedErrorType,
pub source: Option<Box<dyn Error + Sync + Send>>,
pub message: Option<String>,
}
impl fmt::Display for PgEmbedError {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(
f,
"error_type: {:?}\nsource: \n{:?}\nmessage: \n{:?}\n",
self.error_type, self.source, self.message
)
}
}
#[derive(Debug, PartialEq)]
pub enum PgEmbedErrorType {
InvalidPgUrl,
InvalidPgPackage,
WriteFileError,
ReadFileError,
DirCreationError,
UnpackFailure,
PgStartFailure,
PgStopFailure,
PgInitFailure,
PgCleanUpFailure,
PgPurgeFailure,
PgBufferReadError,
PgLockError,
PgProcessError,
PgTimedOutError,
PgTaskJoinError,
PgError,
DownloadFailure,
ConversionFailure,
SendFailure,
SqlQueryError,
MigrationError,
}