Skip to main content

backhopper_xref_reader/
errors.rs

1// Copyright (C) 2026 Michael S. Klishin and Contributors
2// SPDX-License-Identifier: Apache-2.0 OR MIT
3// See LICENSE-APACHE and LICENSE-MIT for details.
4
5use std::path::PathBuf;
6
7use backhopper_core::ModuleName;
8use thiserror::Error;
9
10#[derive(Debug, Error)]
11#[non_exhaustive]
12pub enum ReadError {
13    #[error("invalid utf-8 in {path:?} at byte offset {offset}")]
14    InvalidUtf8 { path: PathBuf, offset: usize },
15}
16
17#[derive(Debug, Clone, PartialEq, Eq)]
18#[non_exhaustive]
19pub enum ReadWarning {
20    EmptyFile {
21        path: PathBuf,
22    },
23    NoModuleAttribute {
24        path: PathBuf,
25    },
26    ConflictingModuleAttribute {
27        path: PathBuf,
28        first: ModuleName,
29        second: ModuleName,
30    },
31    UnsupportedQuotedModuleName {
32        path: PathBuf,
33        raw: String,
34    },
35    AmbiguousApplicationAssignment {
36        path: PathBuf,
37        candidates: Vec<String>,
38    },
39    DuplicateModuleAcrossApplications {
40        name: ModuleName,
41        first_application: Option<String>,
42        second_application: Option<String>,
43    },
44    UnresolvedInclude {
45        path: PathBuf,
46        target: PathBuf,
47    },
48}