Skip to main content

dry4rust/
error.rs

1// Copyright (c) 2026 Matjaz Domen Pecan
2// Copyright 2026 Umberto Gotti <umberto.gotti@umbertogotti.dev>
3// Licensed under the MIT License
4// SPDX-License-Identifier: MIT
5
6use std::io;
7use std::path::PathBuf;
8use std::result::Result as StdResult;
9
10#[derive(Debug, thiserror::Error)]
11pub enum Error {
12    #[error("I/O error: {0}")]
13    Io(#[from] io::Error),
14
15    #[error("No source files found in {0}")]
16    NoSourceFiles(PathBuf),
17
18    #[error("{field} must be {expected}, got {value}")]
19    InvalidConfig {
20        field: &'static str,
21        value: String,
22        expected: &'static str,
23    },
24
25    #[error("baseline {}: {problem}", .path.display())]
26    Baseline { path: PathBuf, problem: String },
27
28    #[error("{0}")]
29    Other(String),
30}
31
32/// Imported under another name because this alias is itself called `Result`:
33/// the right-hand side has to name something other than what it defines.
34pub type Result<T> = StdResult<T, Error>;