grin-wallet/impls/src/error.rs

105 lines
2.7 KiB
Rust
Raw Normal View History

// Copyright 2021 The Grin Developers
2019-02-13 18:05:19 +03:00
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Implementation specific error types
use crate::core::libtx;
use crate::keychain;
use crate::libwallet;
use crate::util::secp;
use grin_wallet_util::OnionV3AddressError;
2019-02-13 18:05:19 +03:00
/// Wallet errors, mostly wrappers around underlying crypto or I/O errors.
#[derive(Clone, thiserror::Error, Eq, PartialEq, Debug)]
pub enum Error {
2019-02-13 18:05:19 +03:00
/// LibTX Error
#[error("LibTx Error")]
LibTX(#[from] libtx::Error),
2019-02-13 18:05:19 +03:00
/// LibWallet Error
#[error("LibWallet Error: {0}")]
LibWallet(#[from] libwallet::Error),
2019-02-13 18:05:19 +03:00
/// Keychain error
#[error("Keychain error")]
Keychain(#[from] keychain::Error),
2019-02-13 18:05:19 +03:00
/// Onion V3 Address Error
#[error("Onion V3 Address Error")]
OnionV3Address(#[from] OnionV3AddressError),
/// Error when obfs4proxy is not in the user path if TOR brigde is enabled
#[error("Unable to find obfs4proxy binary in your path; {}", _0)]
Obfs4proxyBin(String),
/// Error the bridge input is in bad format
#[error("Bridge line is in bad format; {}", _0)]
BridgeLine(String),
2019-02-13 18:05:19 +03:00
/// Error when formatting json
#[error("IO error")]
2019-02-13 18:05:19 +03:00
IO,
/// Secp Error
#[error("Secp error")]
Secp(#[from] secp::Error),
2019-02-13 18:05:19 +03:00
/// Error when formatting json
#[error("Serde JSON error")]
2019-02-13 18:05:19 +03:00
Format,
/// Wallet seed already exists
#[error("Wallet seed file exists: {}", _0)]
2019-02-13 18:05:19 +03:00
WalletSeedExists(String),
/// Wallet seed doesn't exist
#[error("Wallet seed doesn't exist error")]
2019-02-13 18:05:19 +03:00
WalletSeedDoesntExist,
/// Wallet seed doesn't exist
#[error("Wallet doesn't exist at {}. {}", _0, _1)]
WalletDoesntExist(String, String),
2019-02-13 18:05:19 +03:00
/// Enc/Decryption Error
#[error("Enc/Decryption error (check password?)")]
2019-02-13 18:05:19 +03:00
Encryption,
/// BIP 39 word list
#[error("BIP39 Mnemonic (word list) Error")]
2019-02-13 18:05:19 +03:00
Mnemonic,
/// Command line argument error
#[error("{}", _0)]
2019-02-13 18:05:19 +03:00
ArgumentError(String),
/// Tor Bridge error
#[error("Tor Bridge Error: {}", _0)]
TorBridge(String),
/// Tor Proxy error
#[error("Tor Proxy Error: {}", _0)]
TorProxy(String),
/// Generating ED25519 Public Key
#[error("Error generating ed25519 secret key: {}", _0)]
ED25519Key(String),
/// Checking for onion address
#[error("Address is not an Onion v3 Address: {}", _0)]
NotOnion(String),
2019-02-13 18:05:19 +03:00
/// Other
#[error("Generic error: {}", _0)]
2019-02-13 18:05:19 +03:00
GenericError(String),
}