ratman_types/
error.rs

1// SPDX-FileCopyrightText: 2019-2022 Katharina Fey <kookie@spacekookie.de>
2//
3// SPDX-License-Identifier: AGPL-3.0-or-later WITH LicenseRef-AppStore
4
5use async_std::io;
6
7pub type Result<T> = std::result::Result<T, Error>;
8
9#[derive(Debug, thiserror::Error)]
10pub enum Error {
11    #[error("failed to perform system i/o operation: {}", 0)]
12    Io(#[from] io::Error),
13    #[cfg(feature = "proto")]
14    #[error("failed to parse base encoding: {}", 0)]
15    Proto(#[from] protobuf::ProtobufError),
16    #[error("failed to provide correct authentication in handshake")]
17    InvalidAuth,
18}
19
20impl From<Error> for io::Error {
21    fn from(e: Error) -> Self {
22        match e {
23            Error::Io(e) => e,
24            e => panic!("unexpected IPC error: {}", e),
25        }
26    }
27}