swiftide_docker_executor/
errors.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use std::{convert::Infallible, path::StripPrefixError};

use thiserror::Error;

#[derive(Error, Debug)]
pub enum DockerExecutorError {
    #[error("error from bollard")]
    Bollard(#[from] bollard::errors::Error),

    #[error("error building context for image")]
    Context(#[from] ContextError),

    #[error("container state missing for {0}")]
    ContainerStateMissing(String),

    #[error("error initializing client")]
    Init(#[from] ClientError),
}

#[derive(Error, Debug)]
pub enum ContextError {
    #[error("error while trying to ignore files")]
    FailedIgnore(#[from] ignore::Error),

    #[error("failed while walking files in context")]
    Walk(#[from] walkdir::Error),

    #[error("error reading file")]
    Io(#[from] std::io::Error),

    #[error("failed to convert to relative path")]
    RelativePath(#[from] StripPrefixError),
}

#[derive(Error, Debug)]
pub enum ClientError {
    #[error("failed to initialize client")]
    Init(bollard::errors::Error),
}

impl From<Infallible> for DockerExecutorError {
    fn from(_: Infallible) -> Self {
        unreachable!()
    }
}

impl From<Infallible> for ContextError {
    fn from(_: Infallible) -> Self {
        unreachable!()
    }
}