• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wildjames / predictive_coding_rs / 22864321797

09 Mar 2026 04:45PM UTC coverage: 91.047% (-0.6%) from 91.662%
22864321797

push

github

web-flow
Move eval and infer code out to its own module (#13)

* Move eval code out to library. Also, rename the training handler files.

* Move the data handler access to the mod file, to make import paths a bit shorter

* Restructure model access

* Make training imports cleaner

* better import path for ingerence module

* Go through and check for super imports I missed

* Run rust fmt

1582 of 1742 new or added lines in 20 files covered. (90.82%)

2 existing lines in 2 files now uncovered.

1678 of 1843 relevant lines covered (91.05%)

16.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

51.09
/src/error.rs
1
use std::{error::Error as StdError, fmt, io, path::PathBuf, process::ExitStatus};
2

3
// Wrap result to that we always return the custom error type
4
pub type Result<T> = std::result::Result<T, PredictiveCodingError>;
5

6
#[derive(Debug)]
7
pub enum PredictiveCodingError {
8
    Io {
9
        operation: &'static str,
10
        path: PathBuf,
11
        source: io::Error,
12
    },
13
    JsonDeserialize {
14
        path: PathBuf,
15
        source: serde_json::Error,
16
    },
17
    JsonSerialize {
18
        path: PathBuf,
19
        source: serde_json::Error,
20
    },
21
    Csv {
22
        operation: &'static str,
23
        path: PathBuf,
24
        source: csv::Error,
25
    },
26
    Validation {
27
        message: String,
28
    },
29
    InvalidData {
30
        message: String,
31
    },
32
    CommandIo {
33
        command: String,
34
        source: io::Error,
35
    },
36
    CommandFailed {
37
        command: String,
38
        status: ExitStatus,
39
        stderr: String,
40
    },
41
}
42

43
impl PredictiveCodingError {
44
    pub fn io(operation: &'static str, path: impl Into<PathBuf>, source: io::Error) -> Self {
2✔
45
        PredictiveCodingError::Io {
2✔
46
            operation,
2✔
47
            path: path.into(),
2✔
48
            source,
2✔
49
        }
2✔
50
    }
2✔
51

52
    pub fn json_deserialize(path: impl Into<PathBuf>, source: serde_json::Error) -> Self {
2✔
53
        PredictiveCodingError::JsonDeserialize {
2✔
54
            path: path.into(),
2✔
55
            source,
2✔
56
        }
2✔
57
    }
2✔
58

NEW
59
    pub fn json_serialize(path: impl Into<PathBuf>, source: serde_json::Error) -> Self {
×
NEW
60
        PredictiveCodingError::JsonSerialize {
×
NEW
61
            path: path.into(),
×
NEW
62
            source,
×
NEW
63
        }
×
64
    }
×
65

NEW
66
    pub fn csv(operation: &'static str, path: impl Into<PathBuf>, source: csv::Error) -> Self {
×
NEW
67
        PredictiveCodingError::Csv {
×
NEW
68
            operation,
×
NEW
69
            path: path.into(),
×
NEW
70
            source,
×
NEW
71
        }
×
72
    }
×
73

74
    pub fn validation(message: impl Into<String>) -> Self {
3✔
75
        PredictiveCodingError::Validation {
3✔
76
            message: message.into(),
3✔
77
        }
3✔
78
    }
3✔
79

80
    pub fn invalid_data(message: impl Into<String>) -> Self {
1✔
81
        PredictiveCodingError::InvalidData {
1✔
82
            message: message.into(),
1✔
83
        }
1✔
84
    }
1✔
85

86
    pub fn command_io(command: impl Into<String>, source: io::Error) -> Self {
1✔
87
        PredictiveCodingError::CommandIo {
1✔
88
            command: command.into(),
1✔
89
            source,
1✔
90
        }
1✔
91
    }
1✔
92

93
    pub fn command_failed(
1✔
94
        command: impl Into<String>,
1✔
95
        status: ExitStatus,
1✔
96
        stderr: impl Into<String>,
1✔
97
    ) -> Self {
1✔
98
        PredictiveCodingError::CommandFailed {
1✔
99
            command: command.into(),
1✔
100
            status,
1✔
101
            stderr: stderr.into(),
1✔
102
        }
1✔
103
    }
1✔
104
}
105

106
impl fmt::Display for PredictiveCodingError {
107
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2✔
108
        match self {
2✔
109
            PredictiveCodingError::Io {
110
                operation,
2✔
111
                path,
2✔
112
                source,
2✔
113
            } => write!(f, "failed to {operation} {}: {source}", path.display()),
2✔
NEW
114
            PredictiveCodingError::JsonDeserialize { path, source } => {
×
NEW
115
                write!(f, "failed to parse JSON from {}: {source}", path.display())
×
116
            }
NEW
117
            PredictiveCodingError::JsonSerialize { path, source } => {
×
NEW
118
                write!(f, "failed to write JSON to {}: {source}", path.display())
×
119
            }
120
            PredictiveCodingError::Csv {
NEW
121
                operation,
×
NEW
122
                path,
×
NEW
123
                source,
×
NEW
124
            } => write!(
×
NEW
125
                f,
×
126
                "failed to {operation} CSV at {}: {source}",
NEW
127
                path.display()
×
128
            ),
NEW
129
            PredictiveCodingError::Validation { message } => {
×
NEW
130
                write!(f, "validation error: {message}")
×
131
            }
NEW
132
            PredictiveCodingError::InvalidData { message } => write!(f, "invalid data: {message}"),
×
NEW
133
            PredictiveCodingError::CommandIo { command, source } => {
×
NEW
134
                write!(f, "failed to execute command '{command}': {source}")
×
135
            }
136
            PredictiveCodingError::CommandFailed {
NEW
137
                command,
×
NEW
138
                status,
×
NEW
139
                stderr,
×
140
            } => {
NEW
141
                if stderr.trim().is_empty() {
×
NEW
142
                    write!(f, "command '{command}' exited with status {status}")
×
143
                } else {
NEW
144
                    write!(
×
NEW
145
                        f,
×
146
                        "command '{command}' exited with status {status}: {}",
NEW
147
                        stderr.trim()
×
148
                    )
149
                }
150
            }
151
        }
152
    }
2✔
153
}
154

155
impl StdError for PredictiveCodingError {
NEW
156
    fn source(&self) -> Option<&(dyn StdError + 'static)> {
×
NEW
157
        match self {
×
NEW
158
            PredictiveCodingError::Io { source, .. } => Some(source),
×
NEW
159
            PredictiveCodingError::JsonDeserialize { source, .. } => Some(source),
×
NEW
160
            PredictiveCodingError::JsonSerialize { source, .. } => Some(source),
×
NEW
161
            PredictiveCodingError::Csv { source, .. } => Some(source),
×
NEW
162
            PredictiveCodingError::CommandIo { source, .. } => Some(source),
×
163
            PredictiveCodingError::Validation { .. }
164
            | PredictiveCodingError::InvalidData { .. }
NEW
165
            | PredictiveCodingError::CommandFailed { .. } => None,
×
166
        }
167
    }
×
168
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc