Skip to main content

nerdbank_gitversioning/
error.rs

1// Copyright (c) .NET Foundation and Contributors. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4/// An error produced while reading a repository or calculating a version.
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7    /// A version or configuration value has an invalid format.
8    #[error("{0}")]
9    InvalidFormat(String),
10
11    /// An operation cannot be completed in the current state.
12    #[error("{0}")]
13    InvalidOperation(String),
14
15    /// An I/O operation failed.
16    #[error(transparent)]
17    Io(#[from] std::io::Error),
18
19    /// A Git operation failed.
20    #[error(transparent)]
21    Git(#[from] git2::Error),
22
23    /// JSON serialization or deserialization failed.
24    #[error(transparent)]
25    Json(#[from] serde_json::Error),
26}
27
28/// A result returned by this crate.
29pub type Result<T> = std::result::Result<T, Error>;