1use thiserror::Error;
2
3#[derive(Debug)]
5pub struct ProcessCapture {
6 pub stdout: String,
8 pub stderr: String,
10}
11
12#[derive(Error, Debug)]
14pub enum TmpPostgrustError {
15 #[error("subprocess failed to execute")]
17 ExecSubprocessFailed {
18 #[source]
20 source: std::io::Error,
21 command: String,
23 },
24 #[error("subprocess failed to spawn")]
26 SpawnSubprocessFailed(#[source] std::io::Error),
27 #[error("initdb failed")]
29 InitDBFailed(ProcessCapture),
30 #[error("copying cached database failed, file not found")]
32 CopyCachedInitDBFailedFileNotFound(#[source] std::io::Error),
33 #[error("copying cached database failed, could not read file type")]
35 CopyCachedInitDBFailedCouldNotReadFileType(#[source] std::io::Error),
36 #[error("copying cached database failed, could not strip path prefix")]
38 CopyCachedInitDBFailedCouldNotStripPathPrefix(#[source] std::path::StripPrefixError),
39 #[cfg(feature = "tokio-process")]
41 #[error("copying cached database failed, failed to join cp process")]
42 CopyCachedInitDBFailedJoinError(#[source] tokio::task::JoinError),
43 #[error("createdb failed")]
45 CreateDBFailed(ProcessCapture),
46 #[error("failed to write postgresql.conf")]
48 CreateConfigFailed(#[source] std::io::Error),
49 #[error("failed to find temporary data directory")]
51 EmptyDataDirectory,
52 #[error("failed to create unix socket directory")]
54 CreateSocketDirFailed(#[source] std::io::Error),
55 #[error("failed to create cache directory")]
57 CreateCacheDirFailed(#[source] std::io::Error),
58 #[error("failed to create cache directory")]
60 CreateDataDirFailed(#[source] std::io::Error),
61 #[error("updating directory permission to non-root failed")]
63 UpdatingPermissionsFailed(ProcessCapture),
64 #[error("failed to run database migrations")]
66 MigrationsFailed(#[source] Box<dyn std::error::Error + Send + Sync>),
67}
68
69pub type TmpPostgrustResult<T> = Result<T, TmpPostgrustError>;