workspacer_linting/
lint_report.rs1crate::ix!();
3
4#[derive(Debug)]
5pub struct LintReport {
6 stdout: String,
7 stderr: String,
8 success: bool,
9}
10
11impl LintReport {
12
13 pub fn stdout(&self) -> &str {
14 &self.stdout
15 }
16
17 pub fn stderr(&self) -> &str {
18 &self.stderr
19 }
20
21 pub fn success(&self) -> bool {
22 self.success
23 }
24}
25
26impl From<std::process::Output> for LintReport {
27
28 fn from(output: std::process::Output) -> Self {
29 Self {
30 stdout: String::from_utf8_lossy(&output.stdout).to_string(),
31 stderr: String::from_utf8_lossy(&output.stderr).to_string(),
32 success: output.status.success(),
33 }
34 }
35}
36
37impl MaybeThrow for LintReport {
38
39 type Error = LintingError;
40
41 fn maybe_throw(&self) -> Result<(),Self::Error> {
42 if !self.success() {
43 return Err(LintingError::UnknownError {
44 stderr: Some(self.stderr.clone()),
45 stdout: Some(self.stdout.clone()),
46 });
47 }
48
49 Ok(())
50 }
51}