botfair/
result.rs

1// SPDX-Copyright: Copyright (c) 2019 Daniel Edgecumbe (esotericnonsense)
2// SPDX-License-Identifier: AGPL-3.0-only
3//
4// This file is part of botfair.  botfair is free software: you can
5// redistribute it and/or modify it under the terms of the GNU Affero General
6// Public License as published by the Free Software Foundation, either version
7// 3 of the License, or (at your option) any later version.
8//
9// botfair is distributed in the hope that it will be useful, but WITHOUT
10// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License
12// for more details.
13//
14// You should have received a copy of the GNU Affero General Public License
15// along with botfair.  If not, see <http://www.gnu.org/licenses/>.
16
17use crate::generated_exceptions::errorCode;
18
19#[derive(Debug)]
20pub enum Error {
21    Io(std::io::Error),
22    Reqwest(reqwest::Error),
23    APINGException(errorCode),
24    BFLoginFailure(String),
25    BFKeepAliveFailure(crate::client::KeepAliveError), // could be an enum
26    General(String),
27    JSONRPCError,
28    SessionTokenNotPresent,
29    SessionTokenInvalid,
30    Other,
31}
32
33pub type Result<T> = std::result::Result<T, Error>;
34
35impl From<std::io::Error> for Error {
36    fn from(e: std::io::Error) -> Self {
37        Error::Io(e)
38    }
39}
40
41impl From<reqwest::Error> for Error {
42    fn from(e: reqwest::Error) -> Self {
43        Error::Reqwest(e)
44    }
45}