radicle_source/error.rs
1// This file is part of radicle-surf
2// <https://github.com/radicle-dev/radicle-surf>
3//
4// Copyright (C) 2019-2020 The Radicle Team <dev@radicle.xyz>
5//
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License version 3 or
8// later as published by the Free Software Foundation.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <https://www.gnu.org/licenses/>.
17
18use radicle_surf::{file_system, git};
19
20/// An error occurred when interacting with [`radicle_surf`] for browsing source
21/// code.
22#[derive(Debug, thiserror::Error)]
23pub enum Error {
24 /// We expect at least one [`crate::revision::Revisions`] when looking at a
25 /// project, however the computation found none.
26 #[error(
27 "while trying to get user revisions we could not find any, there should be at least one"
28 )]
29 EmptyRevisions,
30
31 /// An error occurred during a [`radicle_surf::file_system`] operation.
32 #[error(transparent)]
33 FileSystem(#[from] file_system::Error),
34
35 /// An error occurred during a [`radicle_surf::git`] operation.
36 #[error(transparent)]
37 Git(#[from] git::error::Error),
38
39 /// When trying to query a repositories branches, but there are none.
40 #[error("the repository has no branches")]
41 NoBranches,
42
43 /// Trying to find a file path which could not be found.
44 #[error("the path '{0}' was not found")]
45 PathNotFound(file_system::Path),
46}